diff --git a/include/wjr/compressed_pair.hpp b/include/wjr/compressed_pair.hpp index 8a642d3a..32ec8dab 100644 --- a/include/wjr/compressed_pair.hpp +++ b/include/wjr/compressed_pair.hpp @@ -1,10 +1,7 @@ #ifndef WJR_COMPRESSED_PAIR_HPP__ #define WJR_COMPRESSED_PAIR_HPP__ -#include - -#include -#include +#include namespace wjr { @@ -206,8 +203,8 @@ class WJR_EMPTY_BASES compressed_pair final : __compressed_pair_base1, template constexpr compressed_pair( - std::piecewise_construct_t, std::tuple tp1, - std::tuple + std::piecewise_construct_t, tuple tp1, + tuple tp2) noexcept(noexcept(compressed_pair(tp1, tp2, std::index_sequence_for{}, std::index_sequence_for{}))) @@ -312,20 +309,12 @@ class WJR_EMPTY_BASES compressed_pair final : __compressed_pair_base1, template constexpr std::tuple_element_t &&get() && noexcept { - if constexpr (I == 0) { - return std::move(first()); - } else { - return std::move(second()); - } + return static_cast &&>(get()); } template constexpr const std::tuple_element_t &&get() const && noexcept { - if constexpr (I == 0) { - return std::move(first()); - } else { - return std::move(second()); - } + return static_cast &&>(get()); } template = 0 && I < 2)> diff --git a/include/wjr/container/generic/bplus_tree.hpp b/include/wjr/container/generic/bplus_tree.hpp index 96315e52..0f8d4be8 100644 --- a/include/wjr/container/generic/bplus_tree.hpp +++ b/include/wjr/container/generic/bplus_tree.hpp @@ -475,12 +475,10 @@ class basic_bplus_tree { basic_bplus_tree(basic_bplus_tree &&other) noexcept( std::is_nothrow_move_constructible_v &&std::is_nothrow_move_constructible_v<_Alty>) - : m_pair(std::piecewise_construct, - std::forward_as_tuple(std::move(other.key_comp())), - std::forward_as_tuple( - std::piecewise_construct, - std::forward_as_tuple(std::move(other.__get_allocator())), - std::forward_as_tuple())) { + : m_pair(std::piecewise_construct, wjr::forward_as_tuple(std::move(other.key_comp())), + wjr::forward_as_tuple(std::piecewise_construct, + wjr::forward_as_tuple(std::move(other.__get_allocator())), + wjr::forward_as_tuple())) { __take_tree(std::move(other)); } diff --git a/include/wjr/container/generic/vector.hpp b/include/wjr/container/generic/vector.hpp index 9ee58f5b..104f33e7 100644 --- a/include/wjr/container/generic/vector.hpp +++ b/include/wjr/container/generic/vector.hpp @@ -990,28 +990,28 @@ class basic_vector { WJR_CONSTEXPR20 explicit basic_vector(const allocator_type &al) noexcept( std::is_nothrow_constructible_v<_Alty, const allocator_type &>) - : m_pair(std::piecewise_construct, std::forward_as_tuple(al), - std::forward_as_tuple()) {} + : m_pair(std::piecewise_construct, wjr::forward_as_tuple(al), + wjr::forward_as_tuple()) {} WJR_CONSTEXPR20 explicit basic_vector(const size_type n, const allocator_type &al = allocator_type()) - : m_pair(std::piecewise_construct, std::forward_as_tuple(al), - std::forward_as_tuple()) { + : m_pair(std::piecewise_construct, wjr::forward_as_tuple(al), + wjr::forward_as_tuple()) { __construct_n(n, vctor); } WJR_CONSTEXPR20 basic_vector(size_type n, const value_type &val, const allocator_type &al = allocator_type()) - : m_pair(std::piecewise_construct, std::forward_as_tuple(al), - std::forward_as_tuple()) { + : m_pair(std::piecewise_construct, wjr::forward_as_tuple(al), + wjr::forward_as_tuple()) { __construct_n(n, val); } private: template WJR_CONSTEXPR20 basic_vector(const basic_vector &other, _Alloc &&al, in_place_empty_t) - : m_pair(std::piecewise_construct, std::forward_as_tuple(al), - std::forward_as_tuple()) { + : m_pair(std::piecewise_construct, wjr::forward_as_tuple(al), + wjr::forward_as_tuple()) { const auto size = other.size(); uninitialized_construct(size, other.capacity()); STraits::uninitialized_copy_n_restrict_using_allocator(other.data(), size, data(), @@ -1023,8 +1023,8 @@ class basic_vector { basic_vector(basic_vector &&other, _Alloc &&al, in_place_empty_t) noexcept( std::is_nothrow_constructible_v &&__storage_noexcept_take_storage) - : m_pair(std::piecewise_construct, std::forward_as_tuple(al), - std::forward_as_tuple()) { + : m_pair(std::piecewise_construct, wjr::forward_as_tuple(al), + wjr::forward_as_tuple()) { __take_storage(std::move(other)); } @@ -1050,8 +1050,8 @@ class basic_vector { template )> WJR_CONSTEXPR20 basic_vector(Iter first, Iter last, const allocator_type &al = allocator_type()) - : m_pair(std::piecewise_construct, std::forward_as_tuple(al), - std::forward_as_tuple()) { + : m_pair(std::piecewise_construct, wjr::forward_as_tuple(al), + wjr::forward_as_tuple()) { __range_construct(try_to_address(first), try_to_address(last), iterator_category_t()); } @@ -1135,12 +1135,12 @@ class basic_vector { WJR_PURE WJR_CONSTEXPR20 pointer __get_pointer(iterator ptr) const noexcept { ptr.check_same_container(this); - return (to_address)(ptr); + return wjr::to_address(ptr); } WJR_PURE WJR_CONSTEXPR20 pointer __get_pointer(const_iterator ptr) const noexcept { ptr.check_same_container(this); - return const_cast((to_address)(ptr)); + return const_cast(wjr::to_address(ptr)); } public: @@ -1412,22 +1412,22 @@ class basic_vector { WJR_CONSTEXPR20 basic_vector(size_type n, dctor_t, const allocator_type &al = allocator_type()) - : m_pair(std::piecewise_construct, std::forward_as_tuple(al), - std::forward_as_tuple()) { + : m_pair(std::piecewise_construct, wjr::forward_as_tuple(al), + wjr::forward_as_tuple()) { __construct_n(n, dctor); } WJR_CONSTEXPR20 basic_vector(size_type n, in_place_reserve_t, const allocator_type &al = allocator_type()) - : m_pair(std::piecewise_construct, std::forward_as_tuple(al), - std::forward_as_tuple()) { + : m_pair(std::piecewise_construct, wjr::forward_as_tuple(al), + wjr::forward_as_tuple()) { uninitialized_construct(0, n); } WJR_CONSTEXPR20 basic_vector(storage_type &&other, const allocator_type &al = allocator_type()) - : m_pair(std::piecewise_construct, std::forward_as_tuple(al), - std::forward_as_tuple()) { + : m_pair(std::piecewise_construct, wjr::forward_as_tuple(al), + wjr::forward_as_tuple()) { take_storage(other); } diff --git a/include/wjr/math/convert.hpp b/include/wjr/math/convert.hpp index 916ee976..ebc1c2e8 100644 --- a/include/wjr/math/convert.hpp +++ b/include/wjr/math/convert.hpp @@ -10,8 +10,9 @@ #include #include #include -#include #include +#include + #if defined(WJR_X86) #include @@ -978,7 +979,7 @@ uint8_t *__fast_to_chars_backward_unchecked_impl(uint8_t *ptr, Value val, IBase template Iter __to_chars_backward_unchecked_impl(Iter first, Value val, IBase ibase, Converter conv) noexcept { - const auto __ptr = reinterpret_cast((to_address)(first)); + const auto __ptr = reinterpret_cast(wjr::to_address(first)); const auto __end = __fast_to_chars_backward_unchecked_impl(__ptr, val, ibase, conv); return first + std::distance(__ptr, __end); } @@ -1243,8 +1244,8 @@ template to_chars_result __to_chars_impl(Iter first, Iter last, Value val, IBase ibase, Converter conv) noexcept { if constexpr (convert_details::__is_fast_convert_iterator_v) { - const auto __first = reinterpret_cast((to_address)(first)); - const auto __last = reinterpret_cast((to_address)(last)); + const auto __first = reinterpret_cast(wjr::to_address(first)); + const auto __last = reinterpret_cast(wjr::to_address(last)); const auto __result = __fast_to_chars_impl(__first, __last, val, ibase, conv); return {first + std::distance(__first, __result.ptr), __result.ec}; } else { @@ -1346,7 +1347,7 @@ Iter __fallback_to_chars_unchecked_impl(Iter ptr, Value val, IBase ibase, } else { \ append(cont, n + sign, dctor); \ } \ - const auto __end = (to_address)(cont.data() + cont.size()); \ + const auto __end = wjr::to_address(cont.data() + cont.size()); \ auto __ptr = (convert_details::fast_buffer_t *) \ __unsigned_to_chars_backward_unchecked( \ (uint8_t *)__end, WJR_PP_QUEUE_EXPAND(CALL), conv); \ @@ -1409,7 +1410,7 @@ template Iter __to_chars_unchecked_impl(Iter ptr, Value val, IBase ibase, Converter conv) noexcept { if constexpr (convert_details::__is_fast_convert_iterator_v) { - const auto __ptr = reinterpret_cast((to_address)(ptr)); + const auto __ptr = reinterpret_cast(wjr::to_address(ptr)); const auto __result = __fast_to_chars_unchecked_impl(__ptr, val, ibase, conv); return ptr + std::distance(__ptr, __result); } else { @@ -1987,13 +1988,13 @@ Iter __fallback_biginteger_large_to_chars_impl(Iter ptr, const uint64_t *up, siz } else { \ append(cont, SIZE, dctor); \ } \ - const auto __ptr = (uint8_t *)(to_address)(cont.data()) + __presize; \ + const auto __ptr = (uint8_t *)wjr::to_address(cont.data()) + __presize; \ const auto __size = NAME(__ptr, WJR_PP_QUEUE_EXPAND(CALL), conv) TAIL; \ WJR_ASSERT((size_t)__size <= SIZE); \ if constexpr (__fast_container_inserter_v == 1) { \ resize(cont, __presize + __size); \ } else { \ - resize(cont, __presize + __size, wjr::dctor); \ + resize(cont, __presize + __size, dctor); \ } \ \ return ptr; \ @@ -2048,7 +2049,7 @@ Iter __biginteger_to_chars_impl(Iter first, const uint64_t *up, size_t n, } if constexpr (convert_details::__is_fast_convert_iterator_v) { - const auto __first = reinterpret_cast((to_address)(first)); + const auto __first = reinterpret_cast(wjr::to_address(first)); const auto __result = __fast_biginteger_large_to_chars_impl(__first, up, n, base, conv); return first + std::distance(__first, __result); @@ -2441,8 +2442,8 @@ template )> void __from_chars_unchecked_impl(Iter first, Iter last, Value &val, IBase ibase, Converter conv) noexcept { - const auto __first = reinterpret_cast((to_address)(first)); - const auto __last = reinterpret_cast((to_address)(last)); + const auto __first = reinterpret_cast(wjr::to_address(first)); + const auto __last = reinterpret_cast(wjr::to_address(last)); __fast_from_chars_unchecked_impl(__first, __last, val, ibase, conv); } @@ -3075,8 +3076,8 @@ uint64_t *biginteger_from_chars(Iter first, Iter last, uint64_t *up, unsigned int base = 10, Converter conv = {}) noexcept { WJR_ASSERT(base <= 36 && (is_zero_or_single_bit(base) || base == 10)); - const auto __first = reinterpret_cast((to_address)(first)); - const auto __last = reinterpret_cast((to_address)(last)); + const auto __first = reinterpret_cast(wjr::to_address(first)); + const auto __last = reinterpret_cast(wjr::to_address(last)); return __biginteger_from_chars_impl(__first, __last, up, base, conv); } diff --git a/include/wjr/memory/copy.hpp b/include/wjr/memory/copy.hpp index ac9c83bb..3cc7db8c 100644 --- a/include/wjr/memory/copy.hpp +++ b/include/wjr/memory/copy.hpp @@ -75,7 +75,7 @@ constexpr OutputIt copy_restrict(InputIt first, InputIt last, OutputIt d_first) const auto __first = try_to_address(std::move(first)); const auto __last = try_to_address(std::move(last)); if constexpr (is_contiguous_iterator_v) { - const auto __d_first = (to_address)(d_first); + const auto __d_first = wjr::to_address(d_first); const auto __d_last = __copy_restrict_impl(__first, __last, __d_first); return std::next(d_first, std::distance(__d_first, __d_last)); } else { @@ -146,7 +146,7 @@ template constexpr OutputIt copy_n_restrict(InputIt first, Size count, OutputIt d_first) { const auto __first = try_to_address(std::move(first)); if constexpr (is_contiguous_iterator_v) { - const auto __d_first = (to_address)(d_first); + const auto __d_first = wjr::to_address(d_first); const auto __d_last = __copy_n_restrict_impl(__first, count, __d_first); return std::next(d_first, std::distance(__d_first, __d_last)); } else { diff --git a/include/wjr/memory/details.hpp b/include/wjr/memory/details.hpp index 0a84e0e3..b9b43f03 100644 --- a/include/wjr/memory/details.hpp +++ b/include/wjr/memory/details.hpp @@ -30,7 +30,7 @@ constexpr auto to_address(const Ptr &p) noexcept { if constexpr (has_pointer_traits_to_address_v>) { return std::pointer_traits>::to_address(p); } else { - return (to_address)(p.operator->()); + return wjr::to_address(p.operator->()); } } @@ -43,7 +43,7 @@ constexpr auto to_address(const Ptr &p) noexcept { */ template >)> constexpr auto to_address(const std::move_iterator &p) noexcept { - return (to_address)(p.base()); + return wjr::to_address(p.base()); } /** @@ -55,7 +55,7 @@ template constexpr decltype(auto) try_to_address(T &&t) noexcept { #if !WJR_HAS_DEBUG(CONTIGUOUS_ITERATOR_CHECK) if constexpr (is_contiguous_iterator_v>) { - return (to_address)(std::forward(t)); + return wjr::to_address(std::forward(t)); } else { #endif return std::forward(t); diff --git a/include/wjr/memory/uninitialized.hpp b/include/wjr/memory/uninitialized.hpp index 8a2ccfee..f81f00db 100644 --- a/include/wjr/memory/uninitialized.hpp +++ b/include/wjr/memory/uninitialized.hpp @@ -18,13 +18,13 @@ namespace wjr { template WJR_CONSTEXPR20 void construct_at(Iter iter, Args &&...args) { - ::new (static_cast((to_address)(iter))) + ::new (static_cast(wjr::to_address(iter))) iterator_value_t(std::forward(args)...); } template WJR_CONSTEXPR20 void construct_at(Iter iter, dctor_t) { - ::new (static_cast((to_address)(iter))) iterator_value_t; + ::new (static_cast(wjr::to_address(iter))) iterator_value_t; } template @@ -33,7 +33,7 @@ WJR_CONSTEXPR20 void uninitialized_construct_using_allocator(Iter iter, Alloc &a if constexpr (is_trivially_allocator_constructible_v) { (construct_at)(iter, std::forward(args)...); } else { - std::allocator_traits::construct(alloc, (to_address)(iter), + std::allocator_traits::construct(alloc, wjr::to_address(iter), std::forward(args)...); } } @@ -44,7 +44,7 @@ WJR_CONSTEXPR20 void uninitialized_construct_using_allocator(Iter iter, Alloc &a if constexpr (is_trivially_allocator_constructible_v) { (construct_at)(iter, dctor_t{}); } else { - std::allocator_traits::construct(alloc, (to_address)(iter)); + std::allocator_traits::construct(alloc, wjr::to_address(iter)); } } @@ -56,7 +56,8 @@ WJR_CONSTEXPR20 OutputIt uninitialized_copy_using_allocator(InputIt first, Input return std::uninitialized_copy(first, last, d_first); } else { for (; first != last; ++first, ++d_first) { - std::allocator_traits::construct(alloc, (to_address)(d_first), *first); + std::allocator_traits::construct(alloc, wjr::to_address(d_first), + *first); } return d_first; } @@ -87,7 +88,7 @@ WJR_CONSTEXPR20 OutputIt uninitialized_copy_restrict_using_allocator(InputIt fir const auto __first = try_to_address(first); const auto __last = try_to_address(last); if constexpr (is_contiguous_iterator_v) { - const auto __d_first = (to_address)(d_first); + const auto __d_first = wjr::to_address(d_first); const auto __d_last = __uninitialized_copy_restrict_using_allocator_impl( __first, __last, __d_first, alloc); return std::next(d_first, std::distance(__d_first, __d_last)); @@ -105,7 +106,8 @@ WJR_CONSTEXPR20 OutputIt uninitialized_copy_n_using_allocator(InputIt first, Siz return std::uninitialized_copy_n(first, n, d_first); } else { for (; n > 0; ++first, ++d_first, --n) { - std::allocator_traits::construct(alloc, (to_address)(d_first), *first); + std::allocator_traits::construct(alloc, wjr::to_address(d_first), + *first); } return d_first; } @@ -135,7 +137,7 @@ WJR_CONSTEXPR20 OutputIt uninitialized_copy_n_restrict_using_allocator(InputIt f Alloc &alloc) { const auto __first = try_to_address(first); if constexpr (is_contiguous_iterator_v) { - const auto __d_first = (to_address)(d_first); + const auto __d_first = wjr::to_address(d_first); const auto __d_last = __uninitialized_copy_n_restrict_using_allocator_impl( __first, n, __d_first, alloc); return std::next(d_first, std::distance(__d_first, __d_last)); @@ -188,7 +190,7 @@ uninitialized_default_construct_using_allocator(Iter first, Iter last, Alloc &al using value_type = iterator_value_t; if constexpr (!std::is_trivially_default_constructible_v) { for (; first != last; ++first) { - std::allocator_traits::construct(alloc, (to_address)(first)); + std::allocator_traits::construct(alloc, wjr::to_address(first)); } } } @@ -203,7 +205,7 @@ WJR_CONSTEXPR20 void uninitialized_default_construct_n_using_allocator(Iter firs using value_type = iterator_value_t; if constexpr (!std::is_trivially_default_constructible_v) { for (; n > 0; ++first, --n) { - std::allocator_traits::construct(alloc, (to_address)(first), + std::allocator_traits::construct(alloc, wjr::to_address(first), value_type()); } } @@ -217,7 +219,7 @@ WJR_CONSTEXPR20 void uninitialized_value_construct_using_allocator(Iter first, I std::uninitialized_value_construct(first, last); } else { for (; first != last; ++first) { - std::allocator_traits::construct(alloc, (to_address)(first)); + std::allocator_traits::construct(alloc, wjr::to_address(first)); } } } @@ -229,7 +231,7 @@ WJR_CONSTEXPR20 void uninitialized_value_construct_n_using_allocator(Iter first, std::uninitialized_value_construct_n(first, n); } else { for (; n > 0; ++first, --n) { - std::allocator_traits::construct(alloc, (to_address)(first)); + std::allocator_traits::construct(alloc, wjr::to_address(first)); } } } @@ -252,7 +254,7 @@ WJR_CONSTEXPR20 void uninitialized_fill_using_allocator(Iter first, Iter last, std::uninitialized_fill(first, last, value); } else { for (; first != last; ++first) { - std::allocator_traits::construct(alloc, (to_address)(first), + std::allocator_traits::construct(alloc, wjr::to_address(first), value); } } @@ -277,7 +279,7 @@ WJR_CONSTEXPR20 void uninitialized_fill_n_using_allocator(Iter first, Size n, std::uninitialized_fill_n(first, n, value); } else { for (; n > 0; ++first, --n) { - std::allocator_traits::construct(alloc, (to_address)(first), + std::allocator_traits::construct(alloc, wjr::to_address(first), value); } } @@ -287,9 +289,9 @@ WJR_CONSTEXPR20 void uninitialized_fill_n_using_allocator(Iter first, Size n, template WJR_CONSTEXPR20 void destroy_at_using_allocator(Iter iter, Alloc &alloc) { if constexpr (is_trivially_allocator_destructible_v) { - std::destroy_at((to_address)(iter)); + std::destroy_at(wjr::to_address(iter)); } else { - std::allocator_traits::destroy(alloc, (to_address)(iter)); + std::allocator_traits::destroy(alloc, wjr::to_address(iter)); } } @@ -299,7 +301,7 @@ WJR_CONSTEXPR20 void destroy_using_allocator(Iter first, Iter last, Alloc &alloc std::destroy(first, last); } else { for (; first != last; ++first) { - std::allocator_traits::destroy(alloc, (to_address)(first)); + std::allocator_traits::destroy(alloc, wjr::to_address(first)); } } } @@ -310,7 +312,7 @@ WJR_CONSTEXPR20 void destroy_n_using_allocator(Iter first, Size n, Alloc &alloc) std::destroy_n(first, n); } else { for (; n > 0; ++first, --n) { - std::allocator_traits::destroy(alloc, (to_address)(first)); + std::allocator_traits::destroy(alloc, wjr::to_address(first)); } } } @@ -408,15 +410,9 @@ class uninitialized : __uninitialized_base_select { return Mybase::m_value; } - constexpr T &&get() && noexcept { - check(true); - return std::move(Mybase::m_value); - } + constexpr T &&get() && noexcept { return static_cast(get()); } - constexpr const T &&get() const && noexcept { - check(true); - return std::move(Mybase::m_value); - } + constexpr const T &&get() const && noexcept { return static_cast(get()); } template )> constexpr T & @@ -444,8 +440,10 @@ class uninitialized : __uninitialized_base_select { constexpr T &operator*() & noexcept { return get(); } constexpr const T &operator*() const & noexcept { return get(); } - constexpr T &&operator*() && noexcept { return std::move(get()); } - constexpr const T &&operator*() const && noexcept { return std::move(get()); } + constexpr T &&operator*() && noexcept { return static_cast(get()); } + constexpr const T &&operator*() const && noexcept { + return static_cast(get()); + } constexpr T *ptr_unsafe() noexcept { return std::addressof(Mybase::m_value); } constexpr const T *ptr_unsafe() const noexcept { diff --git a/include/wjr/span.hpp b/include/wjr/span.hpp index 0a9317fe..22b5be8e 100644 --- a/include/wjr/span.hpp +++ b/include/wjr/span.hpp @@ -160,33 +160,33 @@ class span { #if defined(__cpp_conditional_explicit) template ::value)> constexpr explicit(!__is_dynamic) span(It first, size_type count) noexcept - : storage((to_address)(first), count) {} + : storage(wjr::to_address(first), count) {} #else template ::value &&__is_dynamic)> constexpr span(It first, size_type count) noexcept - : storage((to_address)(first), count) {} + : storage(wjr::to_address(first), count) {} template ::value && !__is_dynamic)> constexpr explicit span(It first, size_type count) noexcept - : storage((to_address)(first), count) {} + : storage(wjr::to_address(first), count) {} #endif #if defined(__cpp_conditional_explicit) template ::value)> constexpr explicit(!__is_dynamic) span(It first, It last) noexcept - : storage((to_address)(first), static_cast(last - first)) {} + : storage(wjr::to_address(first), static_cast(last - first)) {} #else template ::value &&__is_dynamic)> constexpr span(It first, It last) noexcept - : storage((to_address)(first), static_cast(last - first)) {} + : storage(wjr::to_address(first), static_cast(last - first)) {} template ::value && !__is_dynamic)> constexpr explicit span(It first, It last) noexcept - : storage((to_address)(first), static_cast(last - first)) {} + : storage(wjr::to_address(first), static_cast(last - first)) {} #endif template @@ -253,12 +253,12 @@ class span { WJR_PURE WJR_CONSTEXPR20 pointer __get_pointer(iterator ptr) const noexcept { ptr.check_same_container(this); - return (to_address)(ptr); + return wjr::to_address(ptr); } WJR_PURE WJR_CONSTEXPR20 pointer __get_pointer(const_iterator ptr) const noexcept { ptr.check_same_container(this); - return const_cast((to_address)(ptr)); + return const_cast(wjr::to_address(ptr)); } public: diff --git a/include/wjr/tuple.hpp b/include/wjr/tuple.hpp index 61ee2ac5..b1928436 100644 --- a/include/wjr/tuple.hpp +++ b/include/wjr/tuple.hpp @@ -74,6 +74,8 @@ class WJR_EMPTY_BASES tuple_impl, Args...> constexpr static size_t Size = sizeof...(Args); + using Tuple = tuple; + public: template , Args...> : Mybase<_Indexs>(std::forward<_Args>(args))... {} template - constexpr auto &get() & noexcept { + constexpr std::tuple_element_t &get() & noexcept { return Mybase::get(); } template - constexpr const auto &get() const & noexcept { + constexpr const std::tuple_element_t &get() const & noexcept { return Mybase::get(); } template - constexpr auto &&get() && noexcept { - return std::move(Mybase::get()); + constexpr std::tuple_element_t &&get() && noexcept { + return static_cast &&>(get()); } template - constexpr const auto &&get() const && noexcept { - return std::move(Mybase::get()); + constexpr const std::tuple_element_t &&get() const && noexcept { + return static_cast &&>(get()); } }; @@ -246,12 +248,12 @@ class tuple { template constexpr std::tuple_element_t &&get() && noexcept { - return std::move(m_impl.template get()); + return std::move(m_impl).template get(); } template constexpr const std::tuple_element_t &&get() const && noexcept { - return std::move(m_impl.template get()); + return std::move(m_impl).template get(); } template = 0 && I < Size)> @@ -269,13 +271,13 @@ class tuple { template = 0 && I < Size)> constexpr std::tuple_element_t && operator[](integral_constant) && noexcept { - return std::move(get()); + return static_cast &&>(get()); } template = 0 && I < Size)> constexpr const std::tuple_element_t && operator[](integral_constant) const && noexcept { - return std::move(get()); + return static_cast &&>(get()); } private: @@ -369,7 +371,7 @@ template constexpr decltype(auto) tuple_cat(Tuples &&...tuples) { using Helper = __tuple_cat_helper...>; return __tuple_cat_impl(typename Helper::type0{}, typename Helper::type1{}, - forward_as_tuple(std::forward(tuples)...)); + wjr::forward_as_tuple(std::forward(tuples)...)); } template