Commit 22152742 authored by Wez Furlong's avatar Wez Furlong Committed by Facebook Github Bot

folly: workaround AlignedSysAllocator vs Dual ABI issue with gcc

Summary:
`AlignedSysAllocator` doesn't implement the optional `rebind`
or `size_type` portions of the C++ allocator concept.  This is ok
in GCC if the C++11 ABI is in use but causes compilation to fail
with errors like these:

```
folly/Range.h: In instantiation of ‘void folly::Range<Iter>::res
et(folly::Range<Iter>::string<Alloc>&) [with Alloc = folly::AlignedSysAllocator<char>; Iter = const char*; folly::Range<Iter>::string<Alloc> = std::
basic_string<char, std::char_traits<char>, folly::AlignedSysAllocator<char> >]’:
folly/test/RangeTest.cpp:235:18:   required from here
folly/Range.h:420:27: error: ‘folly::Range<const char*>::string<
folly::AlignedSysAllocator<char> >’ {aka ‘const class std::basic_string<char, std::char_traits<char>, folly::AlignedSysAllocator<char> >’} has no me
mber named ‘size’
     reset(str.data(), str.size());
                       ~~~~^~~~
```

This diff works around this issue by only compiling in the problematic
test if the C++11 ABI is enabled.

Reviewed By: yfeldblum

Differential Revision: D14702585

fbshipit-source-id: ea0c5fcfb0d69994d2958c2c236fe002959c824d
parent 8410273e
......@@ -223,6 +223,7 @@ TEST(StringPiece, All) {
EXPECT_EQ(s2, s);
}
#if !defined(__GLIBCXX__) || _GLIBCXX_USE_CXX11_ABI
TEST(StringPiece, CustomAllocator) {
using Alloc = AlignedSysAllocator<char>;
Alloc const alloc{32};
......@@ -235,6 +236,7 @@ TEST(StringPiece, CustomAllocator) {
piece.reset(str);
EXPECT_EQ("foo", piece.subpiece(0, 3));
}
#endif
template <class T>
void expectLT(const T& a, const T& b) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment