{
public:
bad_optional_access() { }
+
virtual const char* what() const noexcept override
- {return "bad optional access";}
+ { return "bad optional access"; }
virtual ~bad_optional_access() noexcept = default;
};
is_trivially_move_assignable<_Tp>::value>
struct _Optional_payload
{
- constexpr _Optional_payload()
- : _M_empty() {}
+ constexpr _Optional_payload() noexcept : _M_empty() { }
template <typename... _Args>
- constexpr _Optional_payload(in_place_t, _Args&&... __args)
- : _M_payload(std::forward<_Args>(__args)...),
- _M_engaged(true) {}
+ constexpr
+ _Optional_payload(in_place_t, _Args&&... __args)
+ : _M_payload(std::forward<_Args>(__args)...), _M_engaged(true) { }
template<typename _Up, typename... _Args>
- constexpr _Optional_payload(std::initializer_list<_Up> __il,
- _Args&&... __args)
+ constexpr
+ _Optional_payload(std::initializer_list<_Up> __il,
+ _Args&&... __args)
: _M_payload(__il, std::forward<_Args>(__args)...),
- _M_engaged(true) {}
+ _M_engaged(true)
+ { }
+
constexpr
_Optional_payload(bool __engaged, const _Optional_payload& __other)
- : _Optional_payload(__other)
- {}
+ : _Optional_payload(__other)
+ { }
constexpr
_Optional_payload(bool __engaged, _Optional_payload&& __other)
- : _Optional_payload(std::move(__other))
- {}
+ : _Optional_payload(std::move(__other))
+ { }
- constexpr _Optional_payload(const _Optional_payload& __other)
+ constexpr
+ _Optional_payload(const _Optional_payload& __other)
{
if (__other._M_engaged)
this->_M_construct(__other._M_payload);
}
- constexpr _Optional_payload(_Optional_payload&& __other)
+ constexpr
+ _Optional_payload(_Optional_payload&& __other)
{
if (__other._M_engaged)
this->_M_construct(std::move(__other._M_payload));
}
using _Stored_type = remove_const_t<_Tp>;
+
struct _Empty_byte { };
+
union {
_Empty_byte _M_empty;
_Stored_type _M_payload;
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
- _M_get() noexcept
- {
- return this->_M_payload;
- }
+ _M_get() noexcept
+ { return this->_M_payload; }
constexpr const _Tp&
- _M_get() const noexcept
- {
- return this->_M_payload;
- }
+ _M_get() const noexcept
+ { return this->_M_payload; }
// _M_reset is a 'safe' operation with no precondition.
void
}
};
- // Payload for constexpr optionals.
+ // Payload for potentially-constexpr optionals.
template <typename _Tp>
struct _Optional_payload<_Tp, true, true, true>
{
- constexpr _Optional_payload()
- : _M_empty(), _M_engaged(false) {}
+ constexpr _Optional_payload() noexcept
+ : _M_empty(), _M_engaged(false) { }
template<typename... _Args>
- constexpr _Optional_payload(in_place_t, _Args&&... __args)
- : _M_payload(std::forward<_Args>(__args)...),
- _M_engaged(true)
- {}
+ constexpr
+ _Optional_payload(in_place_t, _Args&&... __args)
+ : _M_payload(std::forward<_Args>(__args)...), _M_engaged(true)
+ { }
template<typename _Up, typename... _Args>
- constexpr _Optional_payload(std::initializer_list<_Up> __il,
- _Args&&... __args)
+ constexpr
+ _Optional_payload(std::initializer_list<_Up> __il,
+ _Args&&... __args)
: _M_payload(__il, std::forward<_Args>(__args)...),
- _M_engaged(true) {}
+ _M_engaged(true)
+ { }
template <class _Up> struct __ctor_tag {};
- constexpr _Optional_payload(__ctor_tag<bool>,
- const _Tp& __other)
- : _M_payload(__other),
- _M_engaged(true)
- {}
+ constexpr
+ _Optional_payload(__ctor_tag<bool>, const _Tp& __other)
+ : _M_payload(__other), _M_engaged(true)
+ { }
- constexpr _Optional_payload(__ctor_tag<void>)
- : _M_empty(), _M_engaged(false)
- {}
+ constexpr _Optional_payload(__ctor_tag<void>) noexcept
+ : _M_empty(), _M_engaged(false)
+ { }
constexpr _Optional_payload(__ctor_tag<bool>, _Tp&& __other)
- : _M_payload(std::move(__other)),
- _M_engaged(true)
- {}
-
- constexpr _Optional_payload(bool __engaged,
- const _Optional_payload& __other)
- : _Optional_payload(__engaged ?
- _Optional_payload(__ctor_tag<bool>{},
- __other._M_payload) :
- _Optional_payload(__ctor_tag<void>{}))
- {}
-
- constexpr _Optional_payload(bool __engaged,
- _Optional_payload&& __other)
- : _Optional_payload(__engaged
- ? _Optional_payload(__ctor_tag<bool>{},
- std::move(__other._M_payload))
- : _Optional_payload(__ctor_tag<void>{}))
- {}
+ : _M_payload(std::move(__other)), _M_engaged(true)
+ { }
+
+ constexpr
+ _Optional_payload(bool __engaged, const _Optional_payload& __other)
+ : _Optional_payload(__engaged ?
+ _Optional_payload(__ctor_tag<bool>{},
+ __other._M_payload) :
+ _Optional_payload(__ctor_tag<void>{}))
+ { }
+
+ constexpr
+ _Optional_payload(bool __engaged, _Optional_payload&& __other)
+ : _Optional_payload(__engaged
+ ? _Optional_payload(__ctor_tag<bool>{},
+ std::move(__other._M_payload))
+ : _Optional_payload(__ctor_tag<void>{}))
+ { }
using _Stored_type = remove_const_t<_Tp>;
+
struct _Empty_byte { };
+
union {
- _Empty_byte _M_empty;
+ _Empty_byte _M_empty;
_Stored_type _M_payload;
};
bool _M_engaged;
template <typename _Tp>
struct _Optional_payload<_Tp, true, false, true>
{
- constexpr _Optional_payload()
- : _M_empty(), _M_engaged(false) {}
+ constexpr _Optional_payload() noexcept
+ : _M_empty(), _M_engaged(false) { }
template<typename... _Args>
- constexpr _Optional_payload(in_place_t, _Args&&... __args)
- : _M_payload(std::forward<_Args>(__args)...),
- _M_engaged(true)
- {}
+ constexpr
+ _Optional_payload(in_place_t, _Args&&... __args)
+ : _M_payload(std::forward<_Args>(__args)...), _M_engaged(true)
+ { }
template<typename _Up, typename... _Args>
- constexpr _Optional_payload(std::initializer_list<_Up> __il,
- _Args&&... __args)
+ constexpr
+ _Optional_payload(std::initializer_list<_Up> __il,
+ _Args&&... __args)
: _M_payload(__il, std::forward<_Args>(__args)...),
- _M_engaged(true) {}
+ _M_engaged(true)
+ { }
template <class _Up> struct __ctor_tag {};
- constexpr _Optional_payload(__ctor_tag<bool>,
- const _Tp& __other)
- : _M_payload(__other),
- _M_engaged(true)
- {}
+ constexpr _Optional_payload(__ctor_tag<bool>, const _Tp& __other)
+ : _M_payload(__other),
+ _M_engaged(true)
+ { }
- constexpr _Optional_payload(__ctor_tag<void>)
- : _M_empty(), _M_engaged(false)
- {}
+ constexpr _Optional_payload(__ctor_tag<void>) noexcept
+ : _M_empty(), _M_engaged(false)
+ { }
constexpr _Optional_payload(__ctor_tag<bool>, _Tp&& __other)
- : _M_payload(std::move(__other)),
- _M_engaged(true)
- {}
-
- constexpr _Optional_payload(bool __engaged,
- const _Optional_payload& __other)
- : _Optional_payload(__engaged ?
- _Optional_payload(__ctor_tag<bool>{},
- __other._M_payload) :
- _Optional_payload(__ctor_tag<void>{}))
- {}
-
- constexpr _Optional_payload(bool __engaged,
- _Optional_payload&& __other)
- : _Optional_payload(__engaged
- ? _Optional_payload(__ctor_tag<bool>{},
- std::move(__other._M_payload))
- : _Optional_payload(__ctor_tag<void>{}))
- {}
+ : _M_payload(std::move(__other)),
+ _M_engaged(true)
+ { }
+
+ constexpr
+ _Optional_payload(bool __engaged, const _Optional_payload& __other)
+ : _Optional_payload(__engaged ?
+ _Optional_payload(__ctor_tag<bool>{},
+ __other._M_payload) :
+ _Optional_payload(__ctor_tag<void>{}))
+ { }
+
+ constexpr
+ _Optional_payload(bool __engaged, _Optional_payload&& __other)
+ : _Optional_payload(__engaged
+ ? _Optional_payload(__ctor_tag<bool>{},
+ std::move(__other._M_payload))
+ : _Optional_payload(__ctor_tag<void>{}))
+ { }
_Optional_payload(const _Optional_payload&) = default;
_Optional_payload(_Optional_payload&&) = default;
operator=(_Optional_payload&& __other) = default;
using _Stored_type = remove_const_t<_Tp>;
+
struct _Empty_byte { };
+
union {
_Empty_byte _M_empty;
_Stored_type _M_payload;
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
- _M_get() noexcept
- {
- return this->_M_payload;
- }
+ _M_get() noexcept
+ { return this->_M_payload; }
constexpr const _Tp&
- _M_get() const noexcept
- {
- return this->_M_payload;
- }
+ _M_get() const noexcept
+ { return this->_M_payload; }
// _M_reset is a 'safe' operation with no precondition.
void
template <typename _Tp>
struct _Optional_payload<_Tp, true, true, false>
{
- constexpr _Optional_payload()
- : _M_empty(), _M_engaged(false) {}
+ constexpr _Optional_payload() noexcept
+ : _M_empty(), _M_engaged(false) { }
template<typename... _Args>
- constexpr _Optional_payload(in_place_t, _Args&&... __args)
+ constexpr
+ _Optional_payload(in_place_t, _Args&&... __args)
: _M_payload(std::forward<_Args>(__args)...),
_M_engaged(true)
- {}
+ { }
template<typename _Up, typename... _Args>
- constexpr _Optional_payload(std::initializer_list<_Up> __il,
- _Args&&... __args)
+ constexpr
+ _Optional_payload(std::initializer_list<_Up> __il,
+ _Args&&... __args)
: _M_payload(__il, std::forward<_Args>(__args)...),
- _M_engaged(true) {}
+ _M_engaged(true)
+ { }
template <class _Up> struct __ctor_tag {};
- constexpr _Optional_payload(__ctor_tag<bool>,
- const _Tp& __other)
- : _M_payload(__other),
- _M_engaged(true)
- {}
+ constexpr
+ _Optional_payload(__ctor_tag<bool>, const _Tp& __other)
+ : _M_payload(__other),
+ _M_engaged(true)
+ { }
- constexpr _Optional_payload(__ctor_tag<void>)
- : _M_empty(), _M_engaged(false)
- {}
+ constexpr _Optional_payload(__ctor_tag<void>) noexcept
+ : _M_empty(), _M_engaged(false)
+ { }
constexpr _Optional_payload(__ctor_tag<bool>, _Tp&& __other)
- : _M_payload(std::move(__other)),
- _M_engaged(true)
- {}
-
- constexpr _Optional_payload(bool __engaged,
- const _Optional_payload& __other)
- : _Optional_payload(__engaged ?
- _Optional_payload(__ctor_tag<bool>{},
- __other._M_payload) :
- _Optional_payload(__ctor_tag<void>{}))
- {}
-
- constexpr _Optional_payload(bool __engaged,
- _Optional_payload&& __other)
- : _Optional_payload(__engaged
- ? _Optional_payload(__ctor_tag<bool>{},
- std::move(__other._M_payload))
- : _Optional_payload(__ctor_tag<void>{}))
- {}
+ : _M_payload(std::move(__other)),
+ _M_engaged(true)
+ { }
+
+ constexpr
+ _Optional_payload(bool __engaged, const _Optional_payload& __other)
+ : _Optional_payload(__engaged ?
+ _Optional_payload(__ctor_tag<bool>{},
+ __other._M_payload) :
+ _Optional_payload(__ctor_tag<void>{}))
+ { }
+
+ constexpr
+ _Optional_payload(bool __engaged, _Optional_payload&& __other)
+ : _Optional_payload(__engaged
+ ? _Optional_payload(__ctor_tag<bool>{},
+ std::move(__other._M_payload))
+ : _Optional_payload(__ctor_tag<void>{}))
+ { }
_Optional_payload(const _Optional_payload&) = default;
_Optional_payload(_Optional_payload&&) = default;
}
using _Stored_type = remove_const_t<_Tp>;
+
struct _Empty_byte { };
+
union {
_Empty_byte _M_empty;
_Stored_type _M_payload;
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
- _M_get() noexcept
- {
- return this->_M_payload;
- }
+ _M_get() noexcept
+ { return this->_M_payload; }
constexpr const _Tp&
- _M_get() const noexcept
- {
- return this->_M_payload;
- }
+ _M_get() const noexcept
+ { return this->_M_payload; }
// _M_reset is a 'safe' operation with no precondition.
void
template <typename _Tp>
struct _Optional_payload<_Tp, true, false, false>
{
- constexpr _Optional_payload()
- : _M_empty(), _M_engaged(false) {}
+ constexpr _Optional_payload() noexcept
+ : _M_empty(), _M_engaged(false) {}
template<typename... _Args>
- constexpr _Optional_payload(in_place_t, _Args&&... __args)
+ constexpr
+ _Optional_payload(in_place_t, _Args&&... __args)
: _M_payload(std::forward<_Args>(__args)...),
_M_engaged(true)
- {}
+ { }
template<typename _Up, typename... _Args>
- constexpr _Optional_payload(std::initializer_list<_Up> __il,
- _Args&&... __args)
+ constexpr
+ _Optional_payload(std::initializer_list<_Up> __il,
+ _Args&&... __args)
: _M_payload(__il, std::forward<_Args>(__args)...),
- _M_engaged(true) {}
+ _M_engaged(true)
+ { }
template <class _Up> struct __ctor_tag {};
- constexpr _Optional_payload(__ctor_tag<bool>,
- const _Tp& __other)
- : _M_payload(__other),
- _M_engaged(true)
- {}
+ constexpr _Optional_payload(__ctor_tag<bool>, const _Tp& __other)
+ : _M_payload(__other),
+ _M_engaged(true)
+ { }
- constexpr _Optional_payload(__ctor_tag<void>)
- : _M_empty(), _M_engaged(false)
- {}
+ constexpr _Optional_payload(__ctor_tag<void>) noexcept
+ : _M_empty(), _M_engaged(false)
+ { }
constexpr _Optional_payload(__ctor_tag<bool>, _Tp&& __other)
- : _M_payload(std::move(__other)),
- _M_engaged(true)
- {}
-
- constexpr _Optional_payload(bool __engaged,
- const _Optional_payload& __other)
- : _Optional_payload(__engaged ?
- _Optional_payload(__ctor_tag<bool>{},
- __other._M_payload) :
- _Optional_payload(__ctor_tag<void>{}))
- {}
-
- constexpr _Optional_payload(bool __engaged,
- _Optional_payload&& __other)
- : _Optional_payload(__engaged
- ? _Optional_payload(__ctor_tag<bool>{},
- std::move(__other._M_payload))
- : _Optional_payload(__ctor_tag<void>{}))
- {}
+ : _M_payload(std::move(__other)),
+ _M_engaged(true)
+ { }
+
+ constexpr
+ _Optional_payload(bool __engaged, const _Optional_payload& __other)
+ : _Optional_payload(__engaged ?
+ _Optional_payload(__ctor_tag<bool>{},
+ __other._M_payload) :
+ _Optional_payload(__ctor_tag<void>{}))
+ { }
+
+ constexpr
+ _Optional_payload(bool __engaged, _Optional_payload&& __other)
+ : _Optional_payload(__engaged
+ ? _Optional_payload(__ctor_tag<bool>{},
+ std::move(__other._M_payload))
+ : _Optional_payload(__ctor_tag<void>{}))
+ { }
_Optional_payload(const _Optional_payload&) = default;
_Optional_payload(_Optional_payload&&) = default;
}
using _Stored_type = remove_const_t<_Tp>;
+
struct _Empty_byte { };
+
union {
_Empty_byte _M_empty;
_Stored_type _M_payload;
// The _M_get operations have _M_engaged as a precondition.
constexpr _Tp&
- _M_get() noexcept
- {
- return this->_M_payload;
- }
+ _M_get() noexcept
+ { return this->_M_payload; }
constexpr const _Tp&
- _M_get() const noexcept
- {
- return this->_M_payload;
- }
+ _M_get() const noexcept
+ { return this->_M_payload; }
// _M_reset is a 'safe' operation with no precondition.
void
// The _M_construct operation has !_M_engaged as a precondition
// while _M_destruct has _M_engaged as a precondition.
template<typename... _Args>
- void
- _M_construct(_Args&&... __args)
+ void
+ _M_construct(_Args&&... __args)
noexcept(is_nothrow_constructible<_Stored_type, _Args...>())
- {
- ::new
- (std::__addressof(static_cast<_Dp*>(this)->_M_payload._M_payload))
- _Stored_type(std::forward<_Args>(__args)...);
- static_cast<_Dp*>(this)->_M_payload._M_engaged = true;
- }
+ {
+ ::new
+ (std::__addressof(static_cast<_Dp*>(this)->_M_payload._M_payload))
+ _Stored_type(std::forward<_Args>(__args)...);
+ static_cast<_Dp*>(this)->_M_payload._M_engaged = true;
+ }
void
_M_destruct() noexcept
: protected _Optional_base_impl<_Tp, _Optional_base<_Tp>>
{
friend class _Optional_base_impl<_Tp, _Optional_base<_Tp>>;
- public:
+ public:
// Constructors for disengaged optionals.
constexpr _Optional_base() = default;