libstdc++: Cleanup whitespace and type trait usage in <optional>
This makes the formatting in <optional> consistent and also removes redundant && tokens from template arguments for traits like is_constructible and is_convertible. libstdc++-v3/ChangeLog: * include/std/optional (_Optional_payload_base, _Optional_base) (optional, __optional_hash_call_base): Adjust whitespace and other formatting. Remove redundant && tokens on template arguments to type traits.
This commit is contained in:
parent
bcfe4681f9
commit
6e1c9715b3
1 changed files with 107 additions and 102 deletions
|
@ -478,29 +478,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
// Constructors for engaged optionals.
|
||||
template<typename... _Args,
|
||||
enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
|
||||
constexpr explicit _Optional_base(in_place_t, _Args&&... __args)
|
||||
: _M_payload(in_place,
|
||||
std::forward<_Args>(__args)...) { }
|
||||
enable_if_t<is_constructible_v<_Tp, _Args...>, bool> = false>
|
||||
constexpr explicit
|
||||
_Optional_base(in_place_t, _Args&&... __args)
|
||||
: _M_payload(in_place, std::forward<_Args>(__args)...)
|
||||
{ }
|
||||
|
||||
template<typename _Up, typename... _Args,
|
||||
enable_if_t<is_constructible_v<_Tp,
|
||||
initializer_list<_Up>&,
|
||||
_Args&&...>, bool> = false>
|
||||
constexpr explicit _Optional_base(in_place_t,
|
||||
_Args...>, bool> = false>
|
||||
constexpr explicit
|
||||
_Optional_base(in_place_t,
|
||||
initializer_list<_Up> __il,
|
||||
_Args&&... __args)
|
||||
: _M_payload(in_place,
|
||||
__il, std::forward<_Args>(__args)...)
|
||||
: _M_payload(in_place, __il, std::forward<_Args>(__args)...)
|
||||
{ }
|
||||
|
||||
// Copy and move constructors.
|
||||
constexpr _Optional_base(const _Optional_base& __other)
|
||||
: _M_payload(__other._M_payload._M_engaged,
|
||||
__other._M_payload)
|
||||
constexpr
|
||||
_Optional_base(const _Optional_base& __other)
|
||||
: _M_payload(__other._M_payload._M_engaged, __other._M_payload)
|
||||
{ }
|
||||
|
||||
constexpr _Optional_base(_Optional_base&& __other)
|
||||
constexpr
|
||||
_Optional_base(_Optional_base&& __other)
|
||||
noexcept(is_nothrow_move_constructible_v<_Tp>)
|
||||
: _M_payload(__other._M_payload._M_engaged,
|
||||
std::move(__other._M_payload))
|
||||
|
@ -522,26 +524,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
// Constructors for engaged optionals.
|
||||
template<typename... _Args,
|
||||
enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
|
||||
constexpr explicit _Optional_base(in_place_t, _Args&&... __args)
|
||||
: _M_payload(in_place,
|
||||
std::forward<_Args>(__args)...) { }
|
||||
enable_if_t<is_constructible_v<_Tp, _Args...>, bool> = false>
|
||||
constexpr explicit
|
||||
_Optional_base(in_place_t, _Args&&... __args)
|
||||
: _M_payload(in_place, std::forward<_Args>(__args)...)
|
||||
{ }
|
||||
|
||||
template<typename _Up, typename... _Args,
|
||||
enable_if_t<is_constructible_v<_Tp,
|
||||
initializer_list<_Up>&,
|
||||
_Args&&...>, bool> = false>
|
||||
constexpr explicit _Optional_base(in_place_t,
|
||||
_Args...>, bool> = false>
|
||||
constexpr explicit
|
||||
_Optional_base(in_place_t,
|
||||
initializer_list<_Up> __il,
|
||||
_Args&&... __args)
|
||||
: _M_payload(in_place,
|
||||
__il, std::forward<_Args>(__args)...)
|
||||
_Args... __args)
|
||||
: _M_payload(in_place, __il, std::forward<_Args>(__args)...)
|
||||
{ }
|
||||
|
||||
// Copy and move constructors.
|
||||
constexpr _Optional_base(const _Optional_base& __other)
|
||||
: _M_payload(__other._M_payload._M_engaged,
|
||||
__other._M_payload)
|
||||
: _M_payload(__other._M_payload._M_engaged, __other._M_payload)
|
||||
{ }
|
||||
|
||||
constexpr _Optional_base(_Optional_base&& __other) = default;
|
||||
|
@ -562,26 +564,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
// Constructors for engaged optionals.
|
||||
template<typename... _Args,
|
||||
enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
|
||||
constexpr explicit _Optional_base(in_place_t, _Args&&... __args)
|
||||
: _M_payload(in_place,
|
||||
std::forward<_Args>(__args)...) { }
|
||||
enable_if_t<is_constructible_v<_Tp, _Args...>, bool> = false>
|
||||
constexpr explicit
|
||||
_Optional_base(in_place_t, _Args&&... __args)
|
||||
: _M_payload(in_place, std::forward<_Args>(__args)...)
|
||||
{ }
|
||||
|
||||
template<typename _Up, typename... _Args,
|
||||
enable_if_t<is_constructible_v<_Tp,
|
||||
initializer_list<_Up>&,
|
||||
_Args&&...>, bool> = false>
|
||||
constexpr explicit _Optional_base(in_place_t,
|
||||
_Args...>, bool> = false>
|
||||
constexpr explicit
|
||||
_Optional_base(in_place_t,
|
||||
initializer_list<_Up> __il,
|
||||
_Args&&... __args)
|
||||
: _M_payload(in_place,
|
||||
__il, std::forward<_Args>(__args)...)
|
||||
: _M_payload(in_place, __il, std::forward<_Args>(__args)...)
|
||||
{ }
|
||||
|
||||
// Copy and move constructors.
|
||||
constexpr _Optional_base(const _Optional_base& __other) = default;
|
||||
|
||||
constexpr _Optional_base(_Optional_base&& __other)
|
||||
constexpr
|
||||
_Optional_base(_Optional_base&& __other)
|
||||
noexcept(is_nothrow_move_constructible_v<_Tp>)
|
||||
: _M_payload(__other._M_payload._M_engaged,
|
||||
std::move(__other._M_payload))
|
||||
|
@ -603,20 +607,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
// Constructors for engaged optionals.
|
||||
template<typename... _Args,
|
||||
enable_if_t<is_constructible_v<_Tp, _Args&&...>, bool> = false>
|
||||
constexpr explicit _Optional_base(in_place_t, _Args&&... __args)
|
||||
: _M_payload(in_place,
|
||||
std::forward<_Args>(__args)...) { }
|
||||
enable_if_t<is_constructible_v<_Tp, _Args...>, bool> = false>
|
||||
constexpr explicit
|
||||
_Optional_base(in_place_t, _Args&&... __args)
|
||||
: _M_payload(in_place, std::forward<_Args>(__args)...)
|
||||
{ }
|
||||
|
||||
template<typename _Up, typename... _Args,
|
||||
enable_if_t<is_constructible_v<_Tp,
|
||||
initializer_list<_Up>&,
|
||||
_Args&&...>, bool> = false>
|
||||
constexpr explicit _Optional_base(in_place_t,
|
||||
_Args...>, bool> = false>
|
||||
constexpr explicit
|
||||
_Optional_base(in_place_t,
|
||||
initializer_list<_Up> __il,
|
||||
_Args&&... __args)
|
||||
: _M_payload(in_place,
|
||||
__il, std::forward<_Args>(__args)...)
|
||||
: _M_payload(in_place, __il, std::forward<_Args>(__args)...)
|
||||
{ }
|
||||
|
||||
// Copy and move constructors.
|
||||
|
@ -694,8 +699,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
// Converting constructors for engaged optionals.
|
||||
template<typename _Up = _Tp,
|
||||
_Requires<__not_self<_Up>, __not_tag<_Up>,
|
||||
is_constructible<_Tp, _Up&&>,
|
||||
is_convertible<_Up&&, _Tp>> = true>
|
||||
is_constructible<_Tp, _Up>,
|
||||
is_convertible<_Up, _Tp>> = true>
|
||||
constexpr
|
||||
optional(_Up&& __t)
|
||||
noexcept(is_nothrow_constructible_v<_Tp, _Up>)
|
||||
|
@ -703,8 +708,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
template<typename _Up = _Tp,
|
||||
_Requires<__not_self<_Up>, __not_tag<_Up>,
|
||||
is_constructible<_Tp, _Up&&>,
|
||||
__not_<is_convertible<_Up&&, _Tp>>> = false>
|
||||
is_constructible<_Tp, _Up>,
|
||||
__not_<is_convertible<_Up, _Tp>>> = false>
|
||||
explicit constexpr
|
||||
optional(_Up&& __t)
|
||||
noexcept(is_nothrow_constructible_v<_Tp, _Up>)
|
||||
|
@ -738,8 +743,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
template<typename _Up,
|
||||
_Requires<__not_<is_same<_Tp, _Up>>,
|
||||
is_constructible<_Tp, _Up&&>,
|
||||
is_convertible<_Up&&, _Tp>,
|
||||
is_constructible<_Tp, _Up>,
|
||||
is_convertible<_Up, _Tp>,
|
||||
__not_<__converts_from_optional<_Tp, _Up>>> = true>
|
||||
constexpr
|
||||
optional(optional<_Up>&& __t)
|
||||
|
@ -751,8 +756,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
|
||||
template<typename _Up,
|
||||
_Requires<__not_<is_same<_Tp, _Up>>,
|
||||
is_constructible<_Tp, _Up&&>,
|
||||
__not_<is_convertible<_Up&&, _Tp>>,
|
||||
is_constructible<_Tp, _Up>,
|
||||
__not_<is_convertible<_Up, _Tp>>,
|
||||
__not_<__converts_from_optional<_Tp, _Up>>> = false>
|
||||
explicit constexpr
|
||||
optional(optional<_Up>&& __t)
|
||||
|
@ -763,7 +768,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
}
|
||||
|
||||
template<typename... _Args,
|
||||
_Requires<is_constructible<_Tp, _Args&&...>> = false>
|
||||
_Requires<is_constructible<_Tp, _Args...>> = false>
|
||||
explicit constexpr
|
||||
optional(in_place_t, _Args&&... __args)
|
||||
noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
|
||||
|
@ -772,7 +777,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
template<typename _Up, typename... _Args,
|
||||
_Requires<is_constructible<_Tp,
|
||||
initializer_list<_Up>&,
|
||||
_Args&&...>> = false>
|
||||
_Args...>> = false>
|
||||
explicit constexpr
|
||||
optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
|
||||
noexcept(is_nothrow_constructible_v<_Tp, initializer_list<_Up>&,
|
||||
|
@ -859,7 +864,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
}
|
||||
|
||||
template<typename... _Args>
|
||||
enable_if_t<is_constructible_v<_Tp, _Args&&...>, _Tp&>
|
||||
enable_if_t<is_constructible_v<_Tp, _Args...>, _Tp&>
|
||||
emplace(_Args&&... __args)
|
||||
noexcept(is_nothrow_constructible_v<_Tp, _Args...>)
|
||||
{
|
||||
|
@ -869,8 +874,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
}
|
||||
|
||||
template<typename _Up, typename... _Args>
|
||||
enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&,
|
||||
_Args&&...>, _Tp&>
|
||||
enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>,
|
||||
_Tp&>
|
||||
emplace(initializer_list<_Up> __il, _Args&&... __args)
|
||||
noexcept(is_nothrow_constructible_v<_Tp, initializer_list<_Up>&,
|
||||
_Args...>)
|
||||
|
|
Loading…
Add table
Reference in a new issue