Currently I'm trying to convert some of C++'s named requirements to C++20 concepts (https://godbolt.org/z/EdY5d6319 still highly WIP!). However, I stumpled upon a problem.
Given the final C++20 working draft (http://open-std.org/jtc1/sc22/wg21/docs/papers/2020/n4861.pdf):
a == t
where a
denotes a non-const lvalue of type X and t
an lvalue or const rvalue of type X is required. X::value_type
must be CopyAssignable.is_copy_assignable
: is_assignable_v<T&, const T&>
, otherwise false
."std::map
: So std::map<Key, T>
meets the requirements of an allocator-aware container. Therefore, std::map<Key, T>::value_type
must be CopyAssignable.
However, std::map<Key, T>::value_type
is defined as std::pair<const Key, T>
, which is not CopyAssignable due to Key
beeing const
.
Therefore, std::map
does not meet the allocator-aware container requirements, which contradicts page 849 in the standard draft.
What do I miss here?
There's an explicit carve out for this case in [containers.associative.reqmts]/7:
The associative containers meet all the requirements of Allocator-aware containers, except that for
map
andmultimap
, the requirements placed onvalue_type
in Table 76 apply instead tokey_type
andmapped_type
. [ Note: For example, in some caseskey_type
andmapped_type
are required to beCpp17CopyAssignable
even though the associatedvalue_type
,pair<const key_type, mapped_type>
, is notCpp17CopyAssignable
. — end note ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With