@@ -44,8 +44,6 @@ struct Nullable : protected std::optional<T>
44
44
// The following 'using' statement is needed to make visible
45
45
// all constructors of the base class within this derived class.
46
46
//
47
- using std::optional<T>::optional;
48
- using std::optional<T>::value_or;
49
47
using std::optional<T>::value;
50
48
using std::optional<T>::operator *;
51
49
using std::optional<T>::operator ->;
@@ -64,6 +62,18 @@ struct Nullable : protected std::optional<T>
64
62
return std::optional<T>::emplace (std::forward<Args>(args)...);
65
63
}
66
64
65
+ template <typename ... Args>
66
+ constexpr auto ValueOr (Args &&... args) const
67
+ {
68
+ return std::optional<T>::value_or (std::forward<Args>(args)...);
69
+ }
70
+
71
+ template <typename ... Args>
72
+ constexpr auto Value (Args &&... args) const
73
+ {
74
+ return std::optional<T>::value_or (std::forward<Args>(args)...);
75
+ }
76
+
67
77
// For integer types, being nullable involves a range restriction.
68
78
template <
69
79
typename U = std::decay_t <T>,
@@ -109,36 +119,6 @@ struct Nullable : protected std::optional<T>
109
119
bool operator !=(const Nullable<T> & other) const { return !(*this == other); }
110
120
bool operator ==(const T & other) const { return std::optional<T>::has_value () && (**this == other); }
111
121
bool operator !=(const T & other) const { return !(*this == other); }
112
-
113
- // backwards compatibility with old chip::Nullable method names
114
- //
115
- // NOTE: as we transition to std::optional, these should be removed
116
- // We expect only `value` and `value_or` to remain as standard names
117
- // for both nullable and optional.
118
- template <typename ... Args>
119
- auto Value (Args &&... args) -> decltype(std::optional<T>::value(std::forward<Args>(args)...))
120
- {
121
- return std::optional<T>::value (std::forward<Args>(args)...);
122
- }
123
-
124
- template <typename ... Args>
125
- auto Value (Args &&... args) const -> decltype(std::optional<T>::value(std::forward<Args>(args)...))
126
- {
127
- return std::optional<T>::value (std::forward<Args>(args)...);
128
- }
129
-
130
- template <typename ... Args>
131
- auto ValueOr (Args &&... args) -> decltype(std::optional<T>::value_or(std::forward<Args>(args)...))
132
- {
133
- return std::optional<T>::value_or (std::forward<Args>(args)...);
134
- }
135
-
136
- template <typename ... Args>
137
- auto ValueOr (Args &&... args) const -> decltype(std::optional<T>::value_or(std::forward<Args>(args)...))
138
- {
139
- return std::optional<T>::value_or (std::forward<Args>(args)...);
140
- }
141
-
142
122
};
143
123
144
124
template <class T >
0 commit comments