Created on 2022-02-16.00:00:00 last changed 13 months ago
Proposed resolution:
This wording is relative to N4917.
Modify [allocator.uses.construction] as indicated,
using remove_cv_t
in every Constraints: element (paragraphs 4, 6, 8, 10, 12, 14, 17):
Constraints:
remove_cv_t<T>
[is|is not] a specialization ofpair
Add remove_cv_t in paragraph 5:
-5- Returns: A
tuple
value determined as follows:(5.1) — If
uses_allocator_v<remove_cv_t<T>, Alloc>
isfalse
andis_constructible_v<T, Args...>
istrue
, returnforward_as_tuple(std::forward<Args>(args)...)
.(5.2) — Otherwise, if
uses_allocator_v<remove_cv_t<T>, Alloc>
istrue
andis_constructible_v<T, allocator_arg_t, const Alloc&, Args...>
istrue
, returntuple<allocator_arg_t, const Alloc&, Args&&...>( allocator_arg, alloc, std::forward<Args>(args)...)
(5.3) — Otherwise, if
uses_allocator_v<remove_cv_t<T>, Alloc>
istrue
andis_constructible_v<T, Args..., const Alloc&>
istrue
, returnforward_as_tuple(std::forward<Args>(args)..., alloc)
.(5.4) — Otherwise, the program is ill-formed.
Rephrase paragraph 7 in terms of the pair member types:
-?- Let
T1
beT::first_type
. LetT2
beT::second_type
.-6- Constraints:
remove_cv_t<T>
is a specialization ofpair
-7- Effects::
ForEquivalent to:T
specified aspair<T1, T2>
, equivalent
[ 2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Voting → WP. ]
[ 2022-09-30; moved to Tentatively Ready after seven votes in reflector poll ]
[ 2022-09-23; Jonathan provides improved wording ]
[ 2022-08-25; Jonathan Wakely provides wording ]
Previous resolution [SUPERSEDED]:
This wording is relative to N4910.
Modify [allocator.uses.construction] as indicated, using
remove_cv_t
in every Constraints: element:Constraints:
remove_cv_t<T>
[is|is not] a specialization ofpair
[ 2022-08-24; LWG telecon ]
Change every T
to remove_cv_t<T>
.
[ 2022-03-04; Reflector poll ]
Set priority to 2 after reflector poll.
It seems unclear whether cv-qualified pair specializations are considered as specializations of pair in [allocator.uses.construction].
Currently MSVC STL only considered cv-unqualified pair types as such specializations, while libstdc++ accept both cv-unqualified and const-qualified pair types as such specializations. The resolution of LWG 3525 uses remove_cv_t, which possibly imply that the specialization of pair may be cv-qualified. The difference can be observed via the following program:
#include <utility>
#include <memory>
#include <vector>
#include <cassert>
template<class T>
class payload_ator {
int payload{};
public:
payload_ator() = default;
constexpr explicit payload_ator(int n) noexcept : payload{n} {}
template<class U>
constexpr explicit payload_ator(payload_ator<U> a) noexcept : payload{a.payload} {}
friend bool operator==(payload_ator, payload_ator) = default;
template<class U>
friend constexpr bool operator==(payload_ator x, payload_ator<U> y) noexcept
{
return x.payload == y.payload;
}
using value_type = T;
constexpr T* allocate(std::size_t n) { return std::allocator<T>{}.allocate(n); }
constexpr void deallocate(T* p, std::size_t n) { return std::allocator<T>{}.deallocate(p, n); }
constexpr int get_payload() const noexcept { return payload; }
};
bool test()
{
constexpr int in_v = 42;
using my_pair_t = std::pair<int, std::vector<int, payload_ator<int>>>;
auto out_v = std::make_obj_using_allocator<const my_pair_t>(payload_ator<int>{in_v}).second.get_allocator().get_payload();
return in_v == out_v;
}
int main()
{
assert(test()); // passes only if a const-qualified pair specialization is considered as a pair specialization
}
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-22 15:47:43 | admin | set | status: wp -> c++23 |
2022-11-17 00:42:33 | admin | set | messages: + msg13053 |
2022-11-17 00:42:33 | admin | set | status: voting -> wp |
2022-11-08 03:46:49 | admin | set | status: ready -> voting |
2022-10-06 17:09:10 | admin | set | messages: + msg12840 |
2022-10-06 17:09:10 | admin | set | status: open -> ready |
2022-09-23 22:47:01 | admin | set | messages: + msg12806 |
2022-08-25 19:38:43 | admin | set | messages: + msg12716 |
2022-08-25 19:38:43 | admin | set | messages: + msg12715 |
2022-08-25 19:38:43 | admin | set | messages: + msg12714 |
2022-08-25 19:38:43 | admin | set | status: new -> open |
2022-03-04 14:33:52 | admin | set | messages: + msg12400 |
2022-02-16 00:00:00 | admin | create |