Commit 59e15e8f authored by Dan Melnic's avatar Dan Melnic Committed by Facebook GitHub Bot

Fix C++20 build issues

Summary: Fix C++20 build issues

Reviewed By: ispeters

Differential Revision: D31848258

fbshipit-source-id: 55c7029f371f5686e62817712f9900ba4a2b4d0d
parent e2d30a85
...@@ -28,7 +28,8 @@ template <class Alloc> ...@@ -28,7 +28,8 @@ template <class Alloc>
StringPiece stringPieceDup(StringPiece piece, const Alloc& alloc) { StringPiece stringPieceDup(StringPiece piece, const Alloc& alloc) {
auto size = piece.size(); auto size = piece.size();
auto keyDup = auto keyDup =
typename Alloc::template rebind<char>::other(alloc).allocate(size); typename std::allocator_traits<Alloc>::template rebind_alloc<char>(alloc)
.allocate(size);
if (size) { if (size) {
memcpy( memcpy(
keyDup, piece.data(), size * sizeof(typename StringPiece::value_type)); keyDup, piece.data(), size * sizeof(typename StringPiece::value_type));
...@@ -38,8 +39,8 @@ StringPiece stringPieceDup(StringPiece piece, const Alloc& alloc) { ...@@ -38,8 +39,8 @@ StringPiece stringPieceDup(StringPiece piece, const Alloc& alloc) {
template <class Alloc> template <class Alloc>
void stringPieceDel(StringPiece piece, const Alloc& alloc) { void stringPieceDel(StringPiece piece, const Alloc& alloc) {
typename Alloc::template rebind<char>::other(alloc).deallocate( typename std::allocator_traits<Alloc>::template rebind_alloc<char>(alloc)
const_cast<char*>(piece.data()), piece.size()); .deallocate(const_cast<char*>(piece.data()), piece.size());
} }
} // namespace folly } // namespace folly
...@@ -135,6 +135,7 @@ TEST(CoroGTestHelpers, CoReturnByMoveWithImplicitConversionTest) { ...@@ -135,6 +135,7 @@ TEST(CoroGTestHelpers, CoReturnByMoveWithImplicitConversionTest) {
MockFoo mock; MockFoo mock;
struct ImplicitToStringMoveOnly { struct ImplicitToStringMoveOnly {
constexpr ImplicitToStringMoveOnly() noexcept = default;
ImplicitToStringMoveOnly(const ImplicitToStringMoveOnly&) = delete; ImplicitToStringMoveOnly(const ImplicitToStringMoveOnly&) = delete;
ImplicitToStringMoveOnly& operator=(const ImplicitToStringMoveOnly&) = ImplicitToStringMoveOnly& operator=(const ImplicitToStringMoveOnly&) =
delete; delete;
......
...@@ -59,7 +59,7 @@ struct MemoryLeakCheckerAllocator { ...@@ -59,7 +59,7 @@ struct MemoryLeakCheckerAllocator {
: alloc_(other.allocator()) {} : alloc_(other.allocator()) {}
value_type* allocate(size_t n, const void* hint = nullptr) { value_type* allocate(size_t n, const void* hint = nullptr) {
auto p = alloc_.allocate(n, hint); auto p = std::allocator_traits<Alloc>::allocate(alloc_, n, hint);
allocated += n * sizeof(value_type); allocated += n * sizeof(value_type);
return p; return p;
} }
...@@ -69,14 +69,19 @@ struct MemoryLeakCheckerAllocator { ...@@ -69,14 +69,19 @@ struct MemoryLeakCheckerAllocator {
freed += n * sizeof(value_type); freed += n * sizeof(value_type);
} }
size_t max_size() const { return alloc_.max_size(); } size_t max_size() const {
return std::allocator_traits<Alloc>::max_size(alloc_);
}
template <class... Args> template <class... Args>
void construct(value_type* p, Args&&... args) { void construct(value_type* p, Args&&... args) {
alloc_.construct(p, std::forward<Args>(args)...); std::allocator_traits<Alloc>::construct(
alloc_, p, std::forward<Args>(args)...);
} }
void destroy(value_type* p) { alloc_.destroy(p); } void destroy(value_type* p) {
std::allocator_traits<Alloc>::destroy(alloc_, p);
}
template <class U> template <class U>
struct rebind { struct rebind {
......
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