aboutsummaryrefslogtreecommitdiff
path: root/include/tuple
diff options
context:
space:
mode:
Diffstat (limited to 'include/tuple')
-rw-r--r--include/tuple105
1 files changed, 71 insertions, 34 deletions
diff --git a/include/tuple b/include/tuple
index 031d25a9854f..e93824f0aa7f 100644
--- a/include/tuple
+++ b/include/tuple
@@ -19,40 +19,40 @@ namespace std
template <class... T>
class tuple {
public:
- constexpr tuple();
- explicit tuple(const T&...); // constexpr in C++14
+ explicit(see-below) constexpr tuple();
+ explicit(see-below) tuple(const T&...); // constexpr in C++14
template <class... U>
- explicit tuple(U&&...); // constexpr in C++14
+ explicit(see-below) tuple(U&&...); // constexpr in C++14
tuple(const tuple&) = default;
tuple(tuple&&) = default;
template <class... U>
- tuple(const tuple<U...>&); // constexpr in C++14
+ explicit(see-below) tuple(const tuple<U...>&); // constexpr in C++14
template <class... U>
- tuple(tuple<U...>&&); // constexpr in C++14
+ explicit(see-below) tuple(tuple<U...>&&); // constexpr in C++14
template <class U1, class U2>
- tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
+ explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
template <class U1, class U2>
- tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
+ explicit(see-below) tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
// allocator-extended constructors
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a);
template <class Alloc>
- tuple(allocator_arg_t, const Alloc& a, const T&...);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const T&...);
template <class Alloc, class... U>
- tuple(allocator_arg_t, const Alloc& a, U&&...);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, U&&...);
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a, const tuple&);
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a, tuple&&);
template <class Alloc, class... U>
- tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
template <class Alloc, class... U>
- tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
template <class Alloc, class U1, class U2>
- tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
template <class Alloc, class U1, class U2>
- tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
+ explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
tuple& operator=(const tuple&);
tuple&
@@ -69,6 +69,17 @@ public:
void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
};
+template <class ...T>
+tuple(T...) -> tuple<T...>; // since C++17
+template <class T1, class T2>
+tuple(pair<T1, T2>) -> tuple<T1, T2>; // since C++17
+template <class Alloc, class ...T>
+tuple(allocator_arg_t, Alloc, T...) -> tuple<T...>; // since C++17
+template <class Alloc, class T1, class T2>
+tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; // since C++17
+template <class Alloc, class ...T>
+tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since C++17
+
inline constexpr unspecified ignore;
template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
@@ -488,11 +499,19 @@ class _LIBCPP_TEMPLATE_VIS tuple
template <class _Dummy>
struct _CheckArgsConstructor<true, _Dummy>
{
- template <class ..._Args>
- static constexpr bool __enable_default() {
- return __all<is_default_constructible<_Args>::value...>::value;
+ template <int&...>
+ static constexpr bool __enable_implicit_default() {
+ return __all<__is_implicitly_default_constructible<_Tp>::value... >::value;
+ }
+
+ template <int&...>
+ static constexpr bool __enable_explicit_default() {
+ return
+ __all<is_default_constructible<_Tp>::value...>::value &&
+ !__enable_implicit_default< >();
}
+
template <class ..._Args>
static constexpr bool __enable_explicit() {
return
@@ -630,22 +649,26 @@ class _LIBCPP_TEMPLATE_VIS tuple
const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT;
public:
- template <bool _Dummy = true, class = typename enable_if<
- _CheckArgsConstructor<_Dummy>::template __enable_default<_Tp...>()
- >::type>
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR tuple()
+ template <bool _Dummy = true, _EnableIf<
+ _CheckArgsConstructor<_Dummy>::__enable_implicit_default()
+ , void*> = nullptr>
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ tuple()
+ _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
+
+ template <bool _Dummy = true, _EnableIf<
+ _CheckArgsConstructor<_Dummy>::__enable_explicit_default()
+ , void*> = nullptr>
+ explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ tuple()
_NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
tuple(tuple const&) = default;
tuple(tuple&&) = default;
- template <class _AllocArgT, class _Alloc, bool _Dummy = true, class = _EnableIf<
- _And<
- _IsSame<allocator_arg_t, _AllocArgT>,
- __dependent_type<is_default_constructible<_Tp>, _Dummy>...
- >::value
- >
+ template <class _AllocArgT, class _Alloc, _EnableIf<
+ _CheckArgsConstructor<_IsSame<allocator_arg_t, _AllocArgT>::value >::__enable_implicit_default()
+ , void*> = nullptr
>
_LIBCPP_INLINE_VISIBILITY
tuple(_AllocArgT, _Alloc const& __a)
@@ -654,6 +677,17 @@ public:
typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
__tuple_types<_Tp...>()) {}
+ template <class _AllocArgT, class _Alloc, _EnableIf<
+ _CheckArgsConstructor<_IsSame<allocator_arg_t, _AllocArgT>::value>::__enable_explicit_default()
+ , void*> = nullptr
+ >
+ explicit _LIBCPP_INLINE_VISIBILITY
+ tuple(_AllocArgT, _Alloc const& __a)
+ : __base_(allocator_arg_t(), __a,
+ __tuple_indices<>(), __tuple_types<>(),
+ typename __make_tuple_indices<sizeof...(_Tp), 0>::type(),
+ __tuple_types<_Tp...>()) {}
+
template <bool _Dummy = true,
typename enable_if
<
@@ -943,13 +977,16 @@ public:
};
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
-// NOTE: These are not yet standardized, but are required to simulate the
-// implicit deduction guide that should be generated had libc++ declared the
-// tuple-like constructors "correctly"
-template <class _Alloc, class ..._Args>
-tuple(allocator_arg_t, const _Alloc&, tuple<_Args...> const&) -> tuple<_Args...>;
-template <class _Alloc, class ..._Args>
-tuple(allocator_arg_t, const _Alloc&, tuple<_Args...>&&) -> tuple<_Args...>;
+template <class ..._Tp>
+tuple(_Tp...) -> tuple<_Tp...>;
+template <class _Tp1, class _Tp2>
+tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
+template <class _Alloc, class ..._Tp>
+tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>;
+template <class _Alloc, class _Tp1, class _Tp2>
+tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>;
+template <class _Alloc, class ..._Tp>
+tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
#endif
template <class ..._Tp>