Give tuple a constexpr default constructor.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159857 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a0b5befbd3
commit
5394c1ed30
@ -227,7 +227,7 @@ class __tuple_leaf
|
|||||||
|
|
||||||
__tuple_leaf& operator=(const __tuple_leaf&);
|
__tuple_leaf& operator=(const __tuple_leaf&);
|
||||||
public:
|
public:
|
||||||
_LIBCPP_INLINE_VISIBILITY __tuple_leaf() : value()
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf() : value()
|
||||||
{static_assert(!is_reference<_Hp>::value,
|
{static_assert(!is_reference<_Hp>::value,
|
||||||
"Attempted to default construct a reference element in a tuple");}
|
"Attempted to default construct a reference element in a tuple");}
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ class __tuple_leaf<_Ip, _Hp, true>
|
|||||||
|
|
||||||
__tuple_leaf& operator=(const __tuple_leaf&);
|
__tuple_leaf& operator=(const __tuple_leaf&);
|
||||||
public:
|
public:
|
||||||
_LIBCPP_INLINE_VISIBILITY __tuple_leaf() {}
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf() {}
|
||||||
|
|
||||||
template <class _Alloc>
|
template <class _Alloc>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
@ -436,6 +436,9 @@ template<size_t ..._Indx, class ..._Tp>
|
|||||||
struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
|
struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
|
||||||
: public __tuple_leaf<_Indx, _Tp>...
|
: public __tuple_leaf<_Indx, _Tp>...
|
||||||
{
|
{
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
_LIBCPP_CONSTEXPR __tuple_impl() {}
|
||||||
|
|
||||||
template <size_t ..._Uf, class ..._Tf,
|
template <size_t ..._Uf, class ..._Tf,
|
||||||
size_t ..._Ul, class ..._Tl, class ..._Up>
|
size_t ..._Ul, class ..._Tl, class ..._Up>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
@ -531,6 +534,9 @@ class _LIBCPP_VISIBLE tuple
|
|||||||
typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
|
typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
_LIBCPP_CONSTEXPR tuple() {}
|
||||||
|
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
explicit tuple(const _Tp& ... __t)
|
explicit tuple(const _Tp& ... __t)
|
||||||
: base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
|
: base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
|
||||||
@ -687,7 +693,7 @@ class _LIBCPP_VISIBLE tuple<>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
tuple() {}
|
_LIBCPP_CONSTEXPR tuple() {}
|
||||||
template <class _Alloc>
|
template <class _Alloc>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
tuple(allocator_arg_t, const _Alloc&) {}
|
tuple(allocator_arg_t, const _Alloc&) {}
|
||||||
|
@ -46,4 +46,18 @@ int main()
|
|||||||
assert(std::get<2>(t) == "");
|
assert(std::get<2>(t) == "");
|
||||||
assert(std::get<3>(t) == DefaultOnly());
|
assert(std::get<3>(t) == DefaultOnly());
|
||||||
}
|
}
|
||||||
|
#ifndef _LIBCPP_HAS_NO_CONSTEXPR
|
||||||
|
{
|
||||||
|
constexpr std::tuple<> t;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
constexpr std::tuple<int> t;
|
||||||
|
assert(std::get<0>(t) == 0);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
constexpr std::tuple<int, char*> t;
|
||||||
|
assert(std::get<0>(t) == 0);
|
||||||
|
assert(std::get<1>(t) == nullptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user