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>
StringPiece stringPieceDup(StringPiece piece, const Alloc& alloc) {
auto size = piece.size();
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) {
memcpy(
keyDup, piece.data(), size * sizeof(typename StringPiece::value_type));
......@@ -38,8 +39,8 @@ StringPiece stringPieceDup(StringPiece piece, const Alloc& alloc) {
template <class Alloc>
void stringPieceDel(StringPiece piece, const Alloc& alloc) {
typename Alloc::template rebind<char>::other(alloc).deallocate(
const_cast<char*>(piece.data()), piece.size());
typename std::allocator_traits<Alloc>::template rebind_alloc<char>(alloc)
.deallocate(const_cast<char*>(piece.data()), piece.size());
}
} // namespace folly
......@@ -135,6 +135,7 @@ TEST(CoroGTestHelpers, CoReturnByMoveWithImplicitConversionTest) {
MockFoo mock;
struct ImplicitToStringMoveOnly {
constexpr ImplicitToStringMoveOnly() noexcept = default;
ImplicitToStringMoveOnly(const ImplicitToStringMoveOnly&) = delete;
ImplicitToStringMoveOnly& operator=(const ImplicitToStringMoveOnly&) =
delete;
......
......@@ -59,7 +59,7 @@ struct MemoryLeakCheckerAllocator {
: alloc_(other.allocator()) {}
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);
return p;
}
......@@ -69,14 +69,19 @@ struct MemoryLeakCheckerAllocator {
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>
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>
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