diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2016-06-22 22:17:13 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2016-06-22 22:17:13 +0100 |
| commit | a8cf2a84c43ab2ef9ac2b19253ec2bdacd4006f6 (patch) | |
| tree | 7e003e966b89550050a325b99da7a60fb8b0ec8b /src | |
| parent | a2d76e27b08d83bf4eeca7f213546f60089eacfe (diff) | |
Add an Optional::emplace method
Diffstat (limited to 'src')
| -rw-r--r-- | src/optional.hh | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/optional.hh b/src/optional.hh index 3aa3676f..a4d15ff5 100644 --- a/src/optional.hh +++ b/src/optional.hh @@ -60,6 +60,14 @@ public: return false; } + template<typename... Args> + void emplace(Args&&... args) + { + destruct_ifn(); + new (&m_value) T{std::forward<Args>(args)...}; + m_valid = true; + } + T& operator*() { kak_assert(m_valid); |
