summaryrefslogtreecommitdiff
path: root/src/optional.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-09-01 16:54:06 +0700
committerMaxime Coste <mawww@kakoune.org>2017-09-01 16:54:06 +0700
commit9672e9219d43075e04b65a96da0f3dec02a17ca7 (patch)
treefc12a3d55fa069d8ff385e54c3e6c57d7b6bf325 /src/optional.hh
parent4c2ed2062a499c3ab96ec224975bc4f8f802442c (diff)
Code style tweak in optional.hh
Diffstat (limited to 'src/optional.hh')
-rw-r--r--src/optional.hh12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/optional.hh b/src/optional.hh
index 153b5449..dfa84694 100644
--- a/src/optional.hh
+++ b/src/optional.hh
@@ -12,12 +12,12 @@ template<typename T>
struct Optional
{
public:
- constexpr Optional() : m_valid(false) {}
- Optional(const T& other) : m_valid(true) { new (&m_value) T(other); }
- Optional(T&& other) : m_valid(true) { new (&m_value) T(std::move(other)); }
+ constexpr Optional() : m_valid{false} {}
+ Optional(const T& other) : m_valid{true} { new (&m_value) T(other); }
+ Optional(T&& other) : m_valid{true} { new (&m_value) T(std::move(other)); }
Optional(const Optional& other)
- : m_valid(other.m_valid)
+ : m_valid{other.m_valid}
{
if (m_valid)
new (&m_value) T(other.m_value);
@@ -25,7 +25,7 @@ public:
Optional(Optional&& other)
noexcept(noexcept(new (nullptr) T(std::move(other.m_value))))
- : m_valid(other.m_valid)
+ : m_valid{other.m_valid}
{
if (m_valid)
new (&m_value) T(std::move(other.m_value));
@@ -82,7 +82,7 @@ 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}; }
+ T value_or(U&& fallback) const { return m_valid ? m_value : T{std::forward<U>(fallback)}; }
void reset() { destruct_ifn(); m_valid = false; }