24 Ranges library [ranges]

24.7 Range adaptors [range.adaptors]

24.7.2 Semiregular wrapper [range.semi.wrap]

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