File tree 1 file changed +23
-3
lines changed
1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -115,9 +115,29 @@ struct Nullable : protected std::optional<T>
115
115
// NOTE: as we transition to std::optional, these should be removed
116
116
// We expect only `value` and `value_or` to remain as standard names
117
117
// for both nullable and optional.
118
- T & Value () & { return value (); }
119
- const T & Value () const & { return value (); }
120
- const T & ValueOr (const T & defaultValue) const { return value_or (defaultValue); }
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
+ }
121
141
122
142
};
123
143
You can’t perform that action at this time.
0 commit comments