diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-03-14 19:16:46 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-03-14 19:16:46 +0000 |
| commit | b5854ece4383687e41ea69ac6896acd0a894510d (patch) | |
| tree | c7fea52bba5ad073636f3e0e091079131e727f5c /src/optional.hh | |
| parent | 65fd0df0410760ff2a3c3d965b136ffa776c464d (diff) | |
Change ParameterParser switch interface, use an Optional<StringView>
Merge has_option and option_value into a single method get_switch.
Diffstat (limited to 'src/optional.hh')
| -rw-r--r-- | src/optional.hh | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/optional.hh b/src/optional.hh index 60b42fad..a72e1555 100644 --- a/src/optional.hh +++ b/src/optional.hh @@ -72,6 +72,9 @@ public: } const T* operator->() const { return const_cast<Optional&>(*this).operator->(); } + template<typename U> + T value_or(U&& fallback) const { return m_valid ? m_value : T{fallback}; } + private: void destruct_ifn() { if (m_valid) m_value.~T(); } |
