diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2019-12-10 16:15:49 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-12-10 16:15:49 +0000 |
commit | 990a09e486a2fb6170d82580d245e6f013a16904 (patch) | |
tree | ba7f6be93faf6a510d89175f78853abfb82ef518 /libstdc++-v3/include | |
parent | d0d0ba20f2345023e9cec2419c9fb9e6cc7098c6 (diff) | |
download | gcc-990a09e486a2fb6170d82580d245e6f013a16904.zip gcc-990a09e486a2fb6170d82580d245e6f013a16904.tar.gz gcc-990a09e486a2fb6170d82580d245e6f013a16904.tar.bz2 |
libstdc++: Fix bug in std::indirect_result_t
The alias template wasn't working because it applied iter_reference_t to
the pack of iterators before and after passing the pack to the
__indeirect_result helper.
* include/bits/iterator_concepts.h (indirect_result_t): Do not apply
iter_reference_t to parameter pack.
* testsuite/24_iterators/indirect_callable/projected.cc: New test.
From-SVN: r279170
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r-- | libstdc++-v3/include/bits/iterator_concepts.h | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/libstdc++-v3/include/bits/iterator_concepts.h b/libstdc++-v3/include/bits/iterator_concepts.h index 97aed72..ab9851f 100644 --- a/libstdc++-v3/include/bits/iterator_concepts.h +++ b/libstdc++-v3/include/bits/iterator_concepts.h @@ -474,18 +474,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __iter_common_ref : common_reference<iter_reference_t<_Tp>, iter_value_t<_Tp>&> { }; - - // FIXME: needed due to PR c++/67704 - template<typename _Fn, typename... _Is> - struct __indirect_result - { }; - - template<typename _Fn, typename... _Is> - requires (readable<_Is> && ...) - && invocable<_Fn, iter_reference_t<_Is>...> - struct __indirect_result<_Fn, _Is...> - : invoke_result<_Fn, iter_reference_t<_Is>...> - { }; } // namespace __detail template<typename _Tp> @@ -653,15 +641,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION && strict_weak_order<_Fn&, iter_common_reference_t<_I1>, iter_common_reference_t<_I2>>; + namespace __detail + { + // FIXME: needed due to PR c++/67704 + template<typename _Fn, typename... _Is> + struct __indirect_result + { }; + + template<typename _Fn, typename... _Is> + requires (readable<_Is> && ...) + && invocable<_Fn, iter_reference_t<_Is>...> + struct __indirect_result<_Fn, _Is...> + : invoke_result<_Fn, iter_reference_t<_Is>...> + { }; + } // namespace __detail + template<typename _Fn, typename... _Is> using indirect_result_t = typename - __detail::__indirect_result<_Fn, iter_reference_t<_Is>...>::type; + __detail::__indirect_result<_Fn, _Is...>::type; /// [projected], projected template<readable _Iter, indirectly_regular_unary_invocable<_Iter> _Proj> struct projected { using value_type = remove_cvref_t<indirect_result_t<_Proj&, _Iter>>; + indirect_result_t<_Proj&, _Iter> operator*() const; // not defined }; |