Skip to content

Commit e0d00a0

Browse files
committed
Do not expose value/value_or at this time and keep Value/ValueOr as the public API for nullable
1 parent f113924 commit e0d00a0

File tree

1 file changed

+12
-32
lines changed

1 file changed

+12
-32
lines changed

src/app/data-model/Nullable.h

+12-32
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ struct Nullable : protected std::optional<T>
4444
// The following 'using' statement is needed to make visible
4545
// all constructors of the base class within this derived class.
4646
//
47-
using std::optional<T>::optional;
48-
using std::optional<T>::value_or;
4947
using std::optional<T>::value;
5048
using std::optional<T>::operator*;
5149
using std::optional<T>::operator->;
@@ -64,6 +62,18 @@ struct Nullable : protected std::optional<T>
6462
return std::optional<T>::emplace(std::forward<Args>(args)...);
6563
}
6664

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+
6777
// For integer types, being nullable involves a range restriction.
6878
template <
6979
typename U = std::decay_t<T>,
@@ -109,36 +119,6 @@ struct Nullable : protected std::optional<T>
109119
bool operator!=(const Nullable<T> & other) const { return !(*this == other); }
110120
bool operator==(const T & other) const { return std::optional<T>::has_value() && (**this == other); }
111121
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-
142122
};
143123

144124
template <class T>

0 commit comments

Comments
 (0)