From 1489e281b549af8a76a415556c07e147df933a44 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 25 Jul 2024 13:00:09 +0100 Subject: libstdc++: Implement P2968R2 "Making std::ignore a first-class object" This was recently approved for C++26, but we can apply the changes for all modes back to C++11. There's no reason not to make the assignment usable in constant expressions for C++11 mode, and noexcept for all modes. Move the definitions to so they're available in as well as . libstdc++-v3/ChangeLog: * include/bits/utility.h (_Swallow_assign): Make assignment constexpr for C++11 as well, and add noexcept. * include/std/tuple (_Swallow_assign, ignore): Move to bits/utility.h. * testsuite/20_util/headers/utility/ignore.cc: New test. --- libstdc++-v3/include/std/tuple | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'libstdc++-v3/include/std') diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index df3f6e3..93b649e 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -2845,37 +2845,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; #endif - // A class (and instance) which can be used in 'tie' when an element - // of a tuple is not required. - // _GLIBCXX14_CONSTEXPR - // 2933. PR for LWG 2773 could be clearer - struct _Swallow_assign - { - template - _GLIBCXX14_CONSTEXPR const _Swallow_assign& - operator=(const _Tp&) const - { return *this; } - }; - - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 2773. Making std::ignore constexpr - /** Used with `std::tie` to ignore an element of a tuple - * - * When using `std::tie` to assign the elements of a tuple to variables, - * unwanted elements can be ignored by using `std::ignore`. For example: - * - * ``` - * int x, y; - * std::tie(x, std::ignore, y) = std::make_tuple(1, 2, 3); - * ``` - * - * This assignment will perform `x=1; std::ignore=2; y=3;` which results - * in the second element being ignored. - * - * @since C++11 - */ - _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{}; - /// Partial specialization for tuples template struct uses_allocator, _Alloc> : true_type { }; -- cgit v1.1