aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-02-19 23:14:02 -0500
committerPatrick Palka <ppalka@redhat.com>2020-02-20 13:54:43 -0500
commit5586e5060fb6a30ade7a7ef854c21bb89b7065c9 (patch)
tree29cf4865c99a47cf73071272d234b9dbd52c2264 /libstdc++-v3/include
parente6f24f824beb8ba6805702e287bbd6153b472488 (diff)
downloadgcc-5586e5060fb6a30ade7a7ef854c21bb89b7065c9.zip
gcc-5586e5060fb6a30ade7a7ef854c21bb89b7065c9.tar.gz
gcc-5586e5060fb6a30ade7a7ef854c21bb89b7065c9.tar.bz2
libstdc++: Forward second argument of views::iota using the correct type
We are forwarding the second argument of views::iota using the wrong type, causing compile errors when calling views::iota with a value and bound of different types, like in the test case below. libstdc++-v3/ChangeLog: * include/std/ranges (iota_view): Forward declare _Sentinel. (iota_view::_Iterator): Befriend _Sentinel. (iota_view::_Sentinel::_M_equal): New member function. (iota_view::_Sentinel::operator==): Use it. (views::_Iota::operator()): Forward __f using the correct type. * testsuite/std/ranges/access/ssize.cc (test06): Don't call views::iota with integers of different signedness, to appease iota_view's deduction guide. * testsuite/std/ranges/iota/iota_view.cc: Augment test.
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/std/ranges12
1 files changed, 10 insertions, 2 deletions
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 7a66491..6358ce8 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -635,6 +635,8 @@ namespace ranges
class iota_view : public view_interface<iota_view<_Winc, _Bound>>
{
private:
+ struct _Sentinel;
+
struct _Iterator
{
private:
@@ -811,11 +813,17 @@ namespace ranges
private:
_Winc _M_value = _Winc();
+
+ friend _Sentinel;
};
struct _Sentinel
{
private:
+ constexpr bool
+ _M_equal(const _Iterator& __x) const
+ { return __x._M_value == _M_bound; }
+
_Bound _M_bound = _Bound();
public:
@@ -827,7 +835,7 @@ namespace ranges
friend constexpr bool
operator==(const _Iterator& __x, const _Sentinel& __y)
- { return __x._M_value == __y._M_bound; }
+ { return __y._M_equal(__x); }
friend constexpr iter_difference_t<_Winc>
operator-(const _Iterator& __x, const _Sentinel& __y)
@@ -933,7 +941,7 @@ namespace views
template<typename _Tp, typename _Up>
constexpr auto
operator()(_Tp&& __e, _Up&& __f) const
- { return iota_view{std::forward<_Tp>(__e), std::forward<_Tp>(__f)}; }
+ { return iota_view{std::forward<_Tp>(__e), std::forward<_Up>(__f)}; }
};
inline constexpr _Iota iota{};