expected: add constref value constructor

This commit is contained in:
Danny Robson 2019-03-05 23:14:47 +11:00
parent df4e75d2ac
commit b86a9bbdfb

View File

@ -11,6 +11,7 @@
#include <exception> #include <exception>
#include <functional> #include <functional>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
namespace cruft { namespace cruft {
class bad_expected_access : public std::exception { class bad_expected_access : public std::exception {
@ -45,10 +46,16 @@ namespace cruft {
using error_type = ErrorT; using error_type = ErrorT;
expected () = delete; expected () = delete;
expected (expected &&) = default; expected (expected &&);
expected& operator=(expected &&) = default; expected& operator=(expected &&);
expected (expected const&) = default; expected (expected const&);
expected& operator=(expected const&) = default; expected& operator=(expected const&);
expected (ValueT const &_value)
{
::new (&m_store.value) ValueT (_value);
m_valid = true;
}
expected (ValueT &&_value) expected (ValueT &&_value)
{ {