Avoid unneeded default constructor call in Optional

This commit is contained in:
Maxime Coste 2015-06-25 13:36:45 +01:00
parent cc09c36fe0
commit d207d13b68

View File

@ -80,7 +80,11 @@ public:
private: private:
void destruct_ifn() { if (m_valid) m_value.~T(); } 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; bool m_valid;
}; };