Skip to content

Commit f113924

Browse files
committed
Ugly forward of Value and ValueOr .... however at least hopefully it is complete
1 parent 810758c commit f113924

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/app/data-model/Nullable.h

+23-3
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,29 @@ struct Nullable : protected std::optional<T>
115115
// NOTE: as we transition to std::optional, these should be removed
116116
// We expect only `value` and `value_or` to remain as standard names
117117
// 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+
}
121141

122142
};
123143

0 commit comments

Comments
 (0)