While implementing std::experimental::optional (cppreference.com) I got confused by the specification of a specific constructor, namely:
constexpr optional( const T& value ); // (4)
(Source)
This constructor allows optional<T>, for a trivially destructible type T, to be constructed in constexpr context. While the first requirement, namely switching off the user-provided destructor in this case to make optional<T> a literal type, is straight forward to solve, I do not know how to get around the limitation of placement-new not being allowed in constexpr.
I thought I was supposed to implement optional<T> using std::aligned_storage<T> to allow types T that are not default constructible and satisfy any alignment requirements, if applicable. But as I said, constexpr forbids me from using placement new in that particular constructor.
Did I have to much coffee and am not seeing an obvious solution here?
Thank you