Here's the tuple additions for constexpr now that it's ok to return
this.
I'm not quite sure what to do with the get, tie, tuple_cat functions
given the current signatures. Is tuple_cat now considered conforming?
If so, certain signatures can be constexpr.
tested x86/linux
benjamin2011-09-06 Benjamin Kosnik b...@redhat.com
* include/std/tuple (_Tuple_impl::_M_head, _M_tail): Mark constexpr.
(tuple(tuple)): Same.
(tuple(const tuple_UElements... __in)): Same.
(tuple(tuple_UElements... __in)): Same.
(tuple_cat(const tuple_TElements..., const tuple_UElements...)):
Same.
(get): Same.
* include/std/array: Consolidate array::data usage.
* testsuite/23_containers/array/requirements/constexpr_functions.cc:
Remove extra include.
* testsuite/20_util/tuple/creation_functions/constexpr.cc: New.
* testsuite/20_util/tuple/cons/constexpr-2.cc: Add tests.
* testsuite/20_util/tuple/cons/constexpr-3.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust line numbers.
Index: include/std/tuple
===
--- include/std/tuple (revision 178557)
+++ include/std/tuple (working copy)
@@ -143,7 +143,7 @@
_Head
_M_head() noexcept { return *this; }
- const _Head
+ constexpr const _Head
_M_head() const noexcept { return *this; }
};
@@ -189,7 +189,7 @@
_Head
_M_head() noexcept { return _M_head_impl; }
- const _Head
+ constexpr const _Head
_M_head() const noexcept { return _M_head_impl; }
_Head _M_head_impl;
@@ -248,13 +248,13 @@
_Head
_M_head() noexcept { return _Base::_M_head(); }
- const _Head
+ constexpr const _Head
_M_head() const noexcept { return _Base::_M_head(); }
_Inherited
_M_tail() noexcept { return *this; }
- const _Inherited
+ constexpr const _Inherited
_M_tail() const noexcept { return *this; }
constexpr _Tuple_impl()
@@ -280,7 +280,7 @@
_Base(std::forward_Head(__in._M_head())) { }
templatetypename... _UElements
-_Tuple_impl(const _Tuple_impl_Idx, _UElements... __in)
+constexpr _Tuple_impl(const _Tuple_impl_Idx, _UElements... __in)
: _Inherited(__in._M_tail()), _Base(__in._M_head()) { }
templatetypename _UHead, typename... _UTails
@@ -409,7 +409,7 @@
constexpr tuple(const tuple) = default;
- tuple(tuple) = default;
+ constexpr tuple(tuple) = default;
templatetypename... _UElements, typename = typename
enable_if__and_integral_constantbool, sizeof...(_UElements)
@@ -417,7 +417,7 @@
__all_convertible__conv_typesconst _UElements...,
__conv_types_Elements...
::value::type
-tuple(const tuple_UElements... __in)
+constexpr tuple(const tuple_UElements... __in)
: _Inherited(static_castconst _Tuple_impl0, _UElements...(__in))
{ }
@@ -427,7 +427,7 @@
__all_convertible__conv_types_UElements...,
__conv_types_Elements...
::value::type
-tuple(tuple_UElements... __in)
+constexpr tuple(tuple_UElements... __in)
: _Inherited(static_cast_Tuple_impl0, _UElements...(__in)) { }
// Allocator-extended constructors.
@@ -548,18 +548,18 @@
constexpr tuple(const tuple) = default;
- tuple(tuple) = default;
+ constexpr tuple(tuple) = default;
templatetypename _U1, typename _U2, typename = typename
enable_if__and_is_convertibleconst _U1, _T1,
is_convertibleconst _U2, _T2::value::type
-tuple(const tuple_U1, _U2 __in)
+constexpr tuple(const tuple_U1, _U2 __in)
: _Inherited(static_castconst _Tuple_impl0, _U1, _U2(__in)) { }
templatetypename _U1, typename _U2, typename = typename
enable_if__and_is_convertible_U1, _T1,
is_convertible_U2, _T2::value::type
-tuple(tuple_U1, _U2 __in)
+constexpr tuple(tuple_U1, _U2 __in)
: _Inherited(static_cast_Tuple_impl0, _U1, _U2(__in)) { }
templatetypename _U1, typename _U2, typename = typename
@@ -571,7 +571,7 @@
templatetypename _U1, typename _U2, typename = typename
enable_if__and_is_convertible_U1, _T1,
is_convertible_U2, _T2::value::type
- tuple(pair_U1, _U2 __in)
+ constexpr tuple(pair_U1, _U2 __in)
: _Inherited(std::forward_U1(__in.first),
std::forward_U2(__in.second)) { }
@@ -752,7 +752,7 @@
{ return __t._M_head(); }
templatestd::size_t __i, typename _Head, typename... _Tail
-inline typename __add_c_ref_Head::type
+inline constexpr typename __add_c_ref_Head::type
__get_helper(const _Tuple_impl__i, _Head, _Tail... __t) noexcept
{ return __t._M_head(); }
@@ -767,7 +767,7 @@
{ return __get_helper__i(__t); }
templatestd::size_t __i, typename... _Elements
-inline typename __add_c_ref
+inline constexpr typename