https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106320

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot 
gnu.org

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
P2328 constrains the default ctors of various views and iterators.  Some of
these constraints just repeat what is already implicitly required by the
NSDMIs, such as default_initializable<_Vp> in transform_view.  Note that GCC
already treats NSDMIs as part of the "immediate context" when synthesizing a
default constructor, such that if an NSDMI is ill-formed then the constructor
will get defined as deleted.  So these constraints are redundant for GCC at
least, but IIUC this behavior is an extension that other compilers e.g. Clang
don't implement: https://godbolt.org/z/s4a7axYv7.  Backporting these
constraints should be safe since for GCC they have no effect and for other
compilers they'd just make some invalid programs valid.

But P2328 also adds default ctor constraints that weren't already implicitly
required by the NSDMIs, such as default_initializable<_Fp> in transform_view. 
(The corresponding data member _M_fun is always default constructible since it
uses the semiregular wrapper __box.)  We shouldn't have backported _these_
constraints since they cause some views to no longer be default xible.

I think we can salvage the backport by removing the problematic constraints
added by r10-10808-g22b86cdc4d7fdd:

 libstdc++-v3/include/std/ranges | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 17018a5616c..faa55ebceb7 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -518,7 +518,7 @@ namespace ranges
     class single_view : public view_interface<single_view<_Tp>>
     {
     public:
-      single_view() requires default_initializable<_Tp> = default;
+      single_view() = default;

       constexpr explicit
       single_view(const _Tp& __t)
@@ -1592,9 +1592,7 @@ namespace views
       [[no_unique_address]] __detail::_CachedPosition<_Vp> _M_cached_begin;

     public:
-      filter_view() requires (default_initializable<_Vp>
-                             && default_initializable<_Pred>)
-       = default;
+      filter_view() requires default_initializable<_Vp> = default;

       constexpr
       filter_view(_Vp __base, _Pred __pred)
@@ -1940,9 +1938,7 @@ namespace views
       __detail::__box<_Fp> _M_fun;

     public:
-      transform_view() requires (default_initializable<_Vp>
-                                && default_initializable<_Fp>)
-       = default;
+      transform_view() requires default_initializable<_Vp> = default;

       constexpr
       transform_view(_Vp __base, _Fp __fun)
@@ -2220,9 +2216,7 @@ namespace views
       __detail::__box<_Pred> _M_pred;

     public:
-      take_while_view() requires (default_initializable<_Vp>
-                                 && default_initializable<_Pred>)
-       = default;
+      take_while_view() requires default_initializable<_Vp> = default;

       constexpr
       take_while_view(_Vp base, _Pred __pred)
@@ -2389,9 +2383,7 @@ namespace views
       [[no_unique_address]] __detail::_CachedPosition<_Vp> _M_cached_begin;

     public:
-      drop_while_view() requires (default_initializable<_Vp>
-                                 && default_initializable<_Pred>)
-       = default;
+      drop_while_view() requires default_initializable<_Vp> = default;

       constexpr
       drop_while_view(_Vp __base, _Pred __pred)

Reply via email to