Hey this fixes up the array::at issue as pointed out on this list.
In addition, it adds some more tuple markup for constexpr. I'm going to
stage in the tuple work, as some of it is more controversial.
tested x86/linux
-benjamin2011-08-03 Benjamin Kosnik b...@redhat.com
* include/std/tuple: Mark more constructors constexpr.
* testsuite/20_util/tuple/cons/constexpr.cc: Split into and extend as:
* testsuite/20_util/tuple/cons/constexpr-2.cc: ...this.
* testsuite/20_util/tuple/cons/constexpr-3.cc: ... and this.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust line numbers.
2011-08-03 Benjamin Kosnik b...@redhat.com
François Dumont francois.cppd...@free.fr
* testsuite/23_containers/array/at_neg.cc: Move...
* testsuite/23_containers/array/at.cc: ...here. Remove
-fno-exceptions, call const at member function.
Index: include/std/tuple
===
--- include/std/tuple (revision 177290)
+++ include/std/tuple (working copy)
@@ -114,7 +114,7 @@
templatetypename _UHead, typename = typename
enable_if!is_convertible_UHead,
__uses_alloc_base::value::type
-_Head_base(_UHead __h)
+constexpr _Head_base(_UHead __h)
: _Head(std::forward_UHead(__h)) { }
_Head_base(__uses_alloc0)
@@ -140,8 +140,11 @@
_Head_base(__uses_alloc2_Alloc __a, _UHead __uhead)
: _Head(std::forward_UHead(__uhead), *__a._M_a) { }
- _Head _M_head() noexcept { return *this; }
- const _Head _M_head() const noexcept { return *this; }
+ _Head
+ _M_head() noexcept { return *this; }
+
+ const _Head
+ _M_head() const noexcept { return *this; }
};
templatestd::size_t _Idx, typename _Head
@@ -156,7 +159,7 @@
templatetypename _UHead, typename = typename
enable_if!is_convertible_UHead,
__uses_alloc_base::value::type
-_Head_base(_UHead __h)
+constexpr _Head_base(_UHead __h)
: _M_head_impl(std::forward_UHead(__h)) { }
_Head_base(__uses_alloc0)
@@ -183,9 +186,12 @@
_Head_base(__uses_alloc2_Alloc __a, _UHead __uhead)
: _M_head_impl(std::forward_UHead(__uhead), *__a._M_a) { }
- _Head _M_head() noexcept { return _M_head_impl; }
- const _Head _M_head() const noexcept { return _M_head_impl; }
+ _Head
+ _M_head() noexcept { return _M_head_impl; }
+ const _Head
+ _M_head() const noexcept { return _M_head_impl; }
+
_Head _M_head_impl;
};
@@ -239,12 +245,18 @@
typedef _Tuple_impl_Idx + 1, _Tail... _Inherited;
typedef _Head_base_Idx, _Head, std::is_empty_Head::value _Base;
- _Head_M_head() noexcept { return _Base::_M_head(); }
- const _Head _M_head() const noexcept { return _Base::_M_head(); }
+ _Head
+ _M_head() noexcept { return _Base::_M_head(); }
- _Inherited _M_tail() noexcept { return *this; }
- const _Inherited _M_tail() const noexcept { return *this; }
+ const _Head
+ _M_head() const noexcept { return _Base::_M_head(); }
+ _Inherited
+ _M_tail() noexcept { return *this; }
+
+ const _Inherited
+ _M_tail() const noexcept { return *this; }
+
constexpr _Tuple_impl()
: _Inherited(), _Base() { }
@@ -255,7 +267,7 @@
templatetypename _UHead, typename... _UTail, typename = typename
enable_ifsizeof...(_Tail) == sizeof...(_UTail)::type
explicit
-_Tuple_impl(_UHead __head, _UTail... __tail)
+constexpr _Tuple_impl(_UHead __head, _UTail... __tail)
: _Inherited(std::forward_UTail(__tail)...),
_Base(std::forward_UHead(__head)) { }
@@ -371,7 +383,7 @@
}
};
- /// tuple
+ /// Primary class template, tuple
templatetypename... _Elements
class tuple : public _Tuple_impl0, _Elements...
{
@@ -392,10 +404,11 @@
__conv_types_Elements...
::value::type
explicit
-tuple(_UElements... __elements)
+constexpr tuple(_UElements... __elements)
: _Inherited(std::forward_UElements(__elements)...) { }
constexpr tuple(const tuple) = default;
+
tuple(tuple) = default;
templatetypename... _UElements, typename = typename
@@ -417,7 +430,7 @@
tuple(tuple_UElements... __in)
: _Inherited(static_cast_Tuple_impl0, _UElements...(__in)) { }
- // allocator-extended constructors
+ // Allocator-extended constructors.
templatetypename _Alloc
tuple(allocator_arg_t __tag, const _Alloc __a)
@@ -503,6 +516,7 @@
{ _Inherited::_M_swap(__in); }
};
+ // Explicit specialization, zero-element tuple.
template
class tuple
{
@@ -510,7 +524,8 @@
void swap(tuple) noexcept { /* no-op */ }
};
- /// tuple (2-element), with construction and assignment from a pair.