diff options
| author | Marshall Clow <mclow.lists@gmail.com> | 2013-10-05 18:46:37 +0000 |
|---|---|---|
| committer | Marshall Clow <mclow.lists@gmail.com> | 2013-10-05 18:46:37 +0000 |
| commit | de9320aa2b1fa3a77ba656d227310e24e974ff3f (patch) | |
| tree | 85024bedfcedb80e587be808e142834bbc64da5d | |
| parent | 80bd135e7a8bdcaf20513ebe6629f246d0cc920a (diff) | |
| download | bcm5719-llvm-de9320aa2b1fa3a77ba656d227310e24e974ff3f.tar.gz bcm5719-llvm-de9320aa2b1fa3a77ba656d227310e24e974ff3f.zip | |
Implement LWG issue 2275 'forward_as_tuple should be constexpr'
llvm-svn: 192038
| -rw-r--r-- | libcxx/include/tuple | 14 | ||||
| -rw-r--r-- | libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp | 12 |
2 files changed, 15 insertions, 11 deletions
diff --git a/libcxx/include/tuple b/libcxx/include/tuple index 5fa6ef36b53..9f716fb20c8 100644 --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -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))... ), diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp index 148850ee0d6..5e84ff8e882 100644 --- a/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp +++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp @@ -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 } } |

