mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-05-05 08:15:11 -04:00
Extract Optional to own header.
This commit is contained in:
parent
cca8c6dc06
commit
45ae222ab5
2 changed files with 43 additions and 14 deletions
|
@ -29,20 +29,7 @@
|
|||
|
||||
#include "recent_entries.hpp"
|
||||
|
||||
template<typename T>
|
||||
class Optional {
|
||||
public:
|
||||
constexpr Optional() : value_ { }, valid_ { false } { };
|
||||
constexpr Optional(const T& value) : value_ { value }, valid_ { true } { };
|
||||
constexpr Optional(T&& value) : value_ { std::move(value) }, valid_ { true } { };
|
||||
|
||||
bool is_valid() const { return valid_; };
|
||||
T value() const { return value_; };
|
||||
|
||||
private:
|
||||
T value_;
|
||||
bool valid_;
|
||||
};
|
||||
#include "optional.hpp"
|
||||
|
||||
namespace tpms {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue