From d207d13b68a2785cf3829b4b19ad3f2bc4fbb358 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 25 Jun 2015 13:36:45 +0100 Subject: [PATCH] Avoid unneeded default constructor call in Optional --- src/optional.hh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/optional.hh b/src/optional.hh index 67b2352a..cdc7d100 100644 --- a/src/optional.hh +++ b/src/optional.hh @@ -80,7 +80,11 @@ public: private: void destruct_ifn() { if (m_valid) m_value.~T(); } - union { T m_value; }; + union + { + struct {} m_empty; // disable default construction of value + T m_value; + }; bool m_valid; };