23 Ranges library [ranges]

23.8 Range adaptors [range.adaptors]

23.8.2 Semiregular wrapper [range.semi.wrap]

Many of the types in this subclause are specified in terms of an exposition-only class template semiregular.
semiregular<T> behaves exactly like optional<T> with the following differences:
  • semiregular<T> constrains its type parameter T with CopyConstructible<T> && is_­object_­v<T>.
  • If T models DefaultConstructible, the default constructor of semiregular<T> is equivalent to:
    constexpr semiregular() noexcept(is_nothrow_default_constructible_v<T>)
      : semiregular{in_place}
    { }
    
  • If Assignable<T&, const T&> is not satisfied, the copy assignment operator is equivalent to:
    semiregular& operator=(const semiregular& that)
      noexcept(is_nothrow_copy_constructible_v<T>)
    {
      if (that) emplace(*that);
      else reset();
      return *this;
    }
    
  • If Assignable<T&, T> is not satisfied, the move assignment operator is equivalent to:
    semiregular& operator=(semiregular&& that)
      noexcept(is_nothrow_move_constructible_v<T>)
    {
      if (that) emplace(std::move(*that));
      else reset();
      return *this;
    }