[libcxx-commits] [PATCH] D133638: [libc++] static_assert that rebinding the allocator works as expected
Jordan Rupprecht via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 11 13:51:41 PDT 2022
rupprecht added a comment.
I see. That's a surprising result of this patch, and the error message is not very clear. Is there any way a static assert could be added to make it more clear?
Would this be valid way to fix up any breakages with minimal changes? It builds, but will this just hit some other conformance check later?
#include <vector>
struct Foo {
int f;
};
template <typename T = Foo> // <-- Add this
class FooAllocator {
public:
static_assert(std::is_same_v<T, Foo>, "T must be Foo"); // <-- Add this (if desired)
using value_type = Foo;
FooAllocator() = default;
Foo* allocate(size_t num_objects);
void deallocate(Foo* ptr, size_t num_objects);
bool operator==(const FooAllocator&) const { return true; }
bool operator!=(const FooAllocator&) const { return false; }
};
void x() { std::vector<Foo, FooAllocator<>> y; } // <-- FooAllocator is now FooAllocator<>
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133638/new/
https://reviews.llvm.org/D133638
More information about the libcxx-commits
mailing list