Skip to content

Commit

Permalink
implement LWG-3527 (#2194)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Bucior <35536269+AdamBucior@users.noreply.github.com>
Co-authored-by: Alex Guteniev <gutenev@gmail.com>
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
  • Loading branch information
4 people committed Sep 11, 2021
1 parent 75e7d21 commit 1a985bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions stl/inc/xmemory
Expand Up @@ -2140,10 +2140,10 @@ template <class _Ty, class _Alloc, class _Uty1, class _Uty2, enable_if_t<_Is_spe
_NODISCARD constexpr auto uses_allocator_construction_args(const _Alloc& _Al, pair<_Uty1, _Uty2>&& _Pair) noexcept {
// equivalent to
// return _STD uses_allocator_construction_args<_Ty>(_Al, piecewise_construct,
// _STD forward_as_tuple(_STD move(_Pair).first), _STD forward_as_tuple(_STD move(_Pair).second));
// _STD forward_as_tuple(_STD get<0>(_STD move(_Pair)), _STD forward_as_tuple(_STD get<1>(_STD move(_Pair)));
return _STD make_tuple(piecewise_construct,
_STD uses_allocator_construction_args<typename _Ty::first_type>(_Al, _STD move(_Pair).first),
_STD uses_allocator_construction_args<typename _Ty::second_type>(_Al, _STD move(_Pair).second));
_STD uses_allocator_construction_args<typename _Ty::first_type>(_Al, _STD get<0>(_STD move(_Pair))),
_STD uses_allocator_construction_args<typename _Ty::second_type>(_Al, _STD get<1>(_STD move(_Pair))));
}

template <class _Ty, class _Alloc, class... _Types>
Expand Down
Expand Up @@ -179,6 +179,18 @@ void test_GH_2021() { // COMPILE-ONLY
tags[0];
}

struct MoveOnlyType {
MoveOnlyType() = default;
MoveOnlyType(MoveOnlyType&&) = default;
};

void test_LWG3527() { // COMPILE-ONLY
allocator<MoveOnlyType> alloc;
MoveOnlyType obj;
pair<MoveOnlyType&&, MoveOnlyType&&> p{move(obj), move(obj)};
[[maybe_unused]] auto t = uses_allocator_construction_args<pair<MoveOnlyType&&, MoveOnlyType&&>>(alloc, move(p));
}

int main() {
test_P0475R1();

Expand Down

0 comments on commit 1a985bc

Please sign in to comment.