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
[allocator.requirements.general] Consider changing Example 2 #5479
Comments
@jwakely , what do you think? |
I think a normal member instead of hidden friend would be simpler for the equality op. It can even be a non-template, and rely on the converting constructor.
|
While we're here, should we use different template parameter names? |
So: template<class T>
struct SimpleAllocator {
using value_type = T;
SimpleAllocator(ctor args);
template<class U> SimpleAllocator(const SimpleAllocator<U>& other);
[[nodiscard]] T* allocate(std::size_t n);
void deallocate(T* p, std::size_t n);
bool operator==(const SimpleAllocator&) const;
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The example seemly contains some "legacy" styles:
typedef
: nowusing
is preferred;operator!=
: as of C++20, rewritten candidates are generally preferred;Should we change the example as following to encourage preferred styles?
The text was updated successfully, but these errors were encountered: