-
Notifications
You must be signed in to change notification settings - Fork 1.6k
LWG-3170 is_always_equal added to std::allocator makes the standard library treat derived types as always equal #1501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LWG-3170 is_always_equal added to std::allocator makes the standard library treat derived types as always equal #1501
Conversation
|
Thanks for implementing this LWG issue resolution! 😺 I pushed a small change for consistency, although it wasn't a correctness issue. We have machinery (used by Lines 495 to 512 in 19c683d
Although nothing else in the STL uses _Get_is_always_equal, it seemed best to be consistent here.
I manually tested this with: #include <memory>
#include <type_traits>
using namespace std;
template <typename T>
struct UserAlloc : allocator<T> {
UserAlloc() = default;
UserAlloc(const UserAlloc&) = default;
template <typename U>
UserAlloc(const UserAlloc<U>&) {}
template <typename U>
struct rebind {
using other = UserAlloc<U>;
};
};
int main() {
#ifdef ACCESS_DIRECTLY
static_assert(is_same_v<UserAlloc<int>::is_always_equal, true_type>);
#endif
static_assert(is_same_v<allocator_traits<UserAlloc<int>>::is_always_equal, true_type>);
}Finally, as an exception to our |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Thanks for implementing another LWG issue resolution and encouraging users to modernize their code! 🎉 |
Fixes #1466
using is_always_equal = true_type;presents in_Default_allocator_traits, so according to this part of LWG:I've just marked
is_always_equalmember ofstd::allocator<T>as deprecated