Implement LWG issue 2275 'forward_as_tuple should be constexpr'

llvm-svn: 192038
This commit is contained in:
Marshall Clow 2013-10-05 18:46:37 +00:00
parent 80bd135e7a
commit de9320aa2b
2 changed files with 15 additions and 11 deletions

View File

@ -73,7 +73,7 @@ public:
const unspecified ignore;
template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept;
template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
template <class... T> tuple<T&...> tie(T&...) noexcept;
template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
@ -833,14 +833,6 @@ make_tuple(_Tp&&... __t)
template <class... _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
tuple<_Tp&&...>
__forward_as_tuple(_Tp&&... __t) _NOEXCEPT
{
return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
}
template <class... _Tp>
inline _LIBCPP_INLINE_VISIBILITY
tuple<_Tp&&...>
forward_as_tuple(_Tp&&... __t) _NOEXCEPT
{
return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
@ -1041,7 +1033,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
operator()(tuple<_Types...> __t, _Tuple0&& __t0)
{
return __forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))...,
return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))...,
get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
}
@ -1056,7 +1048,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
(__forward_as_tuple(
(forward_as_tuple(
_VSTD::forward<_Types>(get<_I0>(__t))...,
get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
),

View File

@ -51,6 +51,15 @@ test2a(const Tuple& t)
assert(std::get<1>(t) == 'a');
}
#if _LIBCPP_STD_VER > 11
template <class Tuple>
constexpr int
test3(const Tuple& t)
{
return std::tuple_size<Tuple>::value;
}
#endif
int main()
{
{
@ -67,5 +76,8 @@ int main()
double i = 2.5;
char c = 'a';
test2a(std::forward_as_tuple(i, c));
#if _LIBCPP_STD_VER > 11
static_assert ( test3 (std::forward_as_tuple(i, c)) == 2, "" );
#endif
}
}