From Jason Turner

[expected.object.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp9utn3xhn/{from.md → to.md} +11 -13
tmp/tmp9utn3xhn/{from.md → to.md} RENAMED
@@ -19,11 +19,11 @@ namespace std {
19
  template<class U, class G>
20
  constexpr explicit(see below) expected(const expected<U, G>&);
21
  template<class U, class G>
22
  constexpr explicit(see below) expected(expected<U, G>&&);
23
 
24
- template<class U = T>
25
  constexpr explicit(see below) expected(U&& v);
26
 
27
  template<class G>
28
  constexpr explicit(see below) expected(const unexpected<G>&);
29
  template<class G>
@@ -42,11 +42,11 @@ namespace std {
42
  constexpr ~expected();
43
 
44
  // [expected.object.assign], assignment
45
  constexpr expected& operator=(const expected&);
46
  constexpr expected& operator=(expected&&) noexcept(see below);
47
- template<class U = T> constexpr expected& operator=(U&&);
48
  template<class G>
49
  constexpr expected& operator=(const unexpected<G>&);
50
  template<class G>
51
  constexpr expected& operator=(unexpected<G>&&);
52
 
@@ -66,20 +66,20 @@ namespace std {
66
  constexpr T& operator*() & noexcept;
67
  constexpr const T&& operator*() const && noexcept;
68
  constexpr T&& operator*() && noexcept;
69
  constexpr explicit operator bool() const noexcept;
70
  constexpr bool has_value() const noexcept;
71
- constexpr const T& value() const &;
72
- constexpr T& value() &;
73
- constexpr const T&& value() const &&;
74
- constexpr T&& value() &&;
75
  constexpr const E& error() const & noexcept;
76
  constexpr E& error() & noexcept;
77
  constexpr const E&& error() const && noexcept;
78
  constexpr E&& error() && noexcept;
79
- template<class U> constexpr T value_or(U&&) const &;
80
- template<class U> constexpr T value_or(U&&) &&;
81
  template<class G = E> constexpr E error_or(G&&) const &;
82
  template<class G = E> constexpr E error_or(G&&) &&;
83
 
84
  // [expected.object.monadic], monadic operations
85
  template<class F> constexpr auto and_then(F&& f) &;
@@ -116,15 +116,13 @@ namespace std {
116
  };
117
  }
118
  ```
119
 
120
  Any object of type `expected<T, E>` either contains a value of type `T`
121
- or a value of type `E` within its own storage. Implementations are not
122
- permitted to use additional storage, such as dynamic memory, to allocate
123
- the object of type `T` or the object of type `E`. Member *`has_val`*
124
- indicates whether the `expected<T, E>` object contains an object of type
125
- `T`.
126
 
127
  A type `T` is a *valid value type for `expected`*, if `remove_cv_t<T>`
128
  is `void` or a complete non-array object type that is not `in_place_t`,
129
  `unexpect_t`, or a specialization of `unexpected`. A program which
130
  instantiates class template `expected<T, E>` with an argument `T` that
 
19
  template<class U, class G>
20
  constexpr explicit(see below) expected(const expected<U, G>&);
21
  template<class U, class G>
22
  constexpr explicit(see below) expected(expected<U, G>&&);
23
 
24
+ template<class U = remove_cv_t<T>>
25
  constexpr explicit(see below) expected(U&& v);
26
 
27
  template<class G>
28
  constexpr explicit(see below) expected(const unexpected<G>&);
29
  template<class G>
 
42
  constexpr ~expected();
43
 
44
  // [expected.object.assign], assignment
45
  constexpr expected& operator=(const expected&);
46
  constexpr expected& operator=(expected&&) noexcept(see below);
47
+ template<class U = remove_cv_t<T>> constexpr expected& operator=(U&&);
48
  template<class G>
49
  constexpr expected& operator=(const unexpected<G>&);
50
  template<class G>
51
  constexpr expected& operator=(unexpected<G>&&);
52
 
 
66
  constexpr T& operator*() & noexcept;
67
  constexpr const T&& operator*() const && noexcept;
68
  constexpr T&& operator*() && noexcept;
69
  constexpr explicit operator bool() const noexcept;
70
  constexpr bool has_value() const noexcept;
71
+ constexpr const T& value() const &; // freestanding-deleted
72
+ constexpr T& value() &; // freestanding-deleted
73
+ constexpr const T&& value() const &&; // freestanding-deleted
74
+ constexpr T&& value() &&; // freestanding-deleted
75
  constexpr const E& error() const & noexcept;
76
  constexpr E& error() & noexcept;
77
  constexpr const E&& error() const && noexcept;
78
  constexpr E&& error() && noexcept;
79
+ template<class U = remove_cv_t<T>> constexpr T value_or(U&&) const &;
80
+ template<class U = remove_cv_t<T>> constexpr T value_or(U&&) &&;
81
  template<class G = E> constexpr E error_or(G&&) const &;
82
  template<class G = E> constexpr E error_or(G&&) &&;
83
 
84
  // [expected.object.monadic], monadic operations
85
  template<class F> constexpr auto and_then(F&& f) &;
 
116
  };
117
  }
118
  ```
119
 
120
  Any object of type `expected<T, E>` either contains a value of type `T`
121
+ or a value of type `E` nested within [[intro.object]] it. Member
122
+ *`has_val`* indicates whether the `expected<T, E>` object contains an
123
+ object of type `T`.
 
 
124
 
125
  A type `T` is a *valid value type for `expected`*, if `remove_cv_t<T>`
126
  is `void` or a complete non-array object type that is not `in_place_t`,
127
  `unexpect_t`, or a specialization of `unexpected`. A program which
128
  instantiates class template `expected<T, E>` with an argument `T` that