_Head&
_M_head() noexcept { return *this; }
- const _Head&
+ constexpr const _Head&
_M_head() const noexcept { return *this; }
};
_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;
_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()
_Base(std::forward<_Head>(__in._M_head())) { }
template<typename... _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()) { }
template<typename _UHead, typename... _UTails>
constexpr tuple(const tuple&) = default;
- tuple(tuple&&) = default;
+ constexpr tuple(tuple&&) = default;
template<typename... _UElements, typename = typename
enable_if<__and_<integral_constant<bool, sizeof...(_UElements)
__all_convertible<__conv_types<const _UElements&...>,
__conv_types<_Elements...>>
>::value>::type>
- tuple(const tuple<_UElements...>& __in)
+ constexpr tuple(const tuple<_UElements...>& __in)
: _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
{ }
__all_convertible<__conv_types<_UElements...>,
__conv_types<_Elements...>>
>::value>::type>
- tuple(tuple<_UElements...>&& __in)
+ constexpr tuple(tuple<_UElements...>&& __in)
: _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
// Allocator-extended constructors.
constexpr tuple(const tuple&) = default;
- tuple(tuple&&) = default;
+ constexpr tuple(tuple&&) = default;
template<typename _U1, typename _U2, typename = typename
enable_if<__and_<is_convertible<const _U1&, _T1>,
is_convertible<const _U2&, _T2>>::value>::type>
- tuple(const tuple<_U1, _U2>& __in)
+ constexpr tuple(const tuple<_U1, _U2>& __in)
: _Inherited(static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in)) { }
template<typename _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_impl<0, _U1, _U2>&&>(__in)) { }
template<typename _U1, typename _U2, typename = typename
template<typename _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)) { }
{ return __t._M_head(); }
template<std::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(); }
{ return __get_helper<__i>(__t); }
template<std::size_t __i, typename... _Elements>
- inline typename __add_c_ref<
+ inline constexpr typename __add_c_ref<
typename tuple_element<__i, tuple<_Elements...>>::type
>::type
get(const tuple<_Elements...>& __t) noexcept
template<std::size_t __i, std::size_t __j, typename _Tp, typename _Up>
struct __tuple_compare<0, __i, __j, _Tp, _Up>
{
- static bool __eq(const _Tp& __t, const _Up& __u)
+ static bool
+ __eq(const _Tp& __t, const _Up& __u)
{
return (get<__i>(__t) == get<__i>(__u) &&
__tuple_compare<0, __i + 1, __j, _Tp, _Up>::__eq(__t, __u));
}
- static bool __less(const _Tp& __t, const _Up& __u)
+ static bool
+ __less(const _Tp& __t, const _Up& __u)
{
return ((get<__i>(__t) < get<__i>(__u))
|| !(get<__i>(__u) < get<__i>(__t)) &&
template<std::size_t __i, typename _Tp, typename _Up>
struct __tuple_compare<0, __i, __i, _Tp, _Up>
{
- static bool __eq(const _Tp&, const _Up&)
- { return true; }
+ static bool
+ __eq(const _Tp&, const _Up&) { return true; }
- static bool __less(const _Tp&, const _Up&)
- { return false; }
+ static bool
+ __less(const _Tp&, const _Up&) { return false; }
};
template<typename... _TElements, typename... _UElements>
template<typename... _TElements, std::size_t... _TIdx,
typename... _UElements, std::size_t... _UIdx>
- inline tuple<_TElements..., _UElements...>
+ inline constexpr tuple<_TElements..., _UElements...>
__tuple_cat_helper(const tuple<_TElements...>& __t,
const __index_holder<_TIdx...>&,
const tuple<_UElements...>& __u,
std::forward<_UElements>(get<_UIdx>(__u))...); }
template<typename... _TElements, typename... _UElements>
- inline tuple<_TElements..., _UElements...>
+ inline constexpr tuple<_TElements..., _UElements...>
tuple_cat(const tuple<_TElements...>& __t, const tuple<_UElements...>& __u)
{
return __tuple_cat_helper(__t, typename
template<class _T1, class _T2>
template<typename _Tp, typename... _Args>
inline _Tp
- pair<_T1, _T2>::
- __cons(tuple<_Args...>&& __tuple)
+ pair<_T1, _T2>::__cons(tuple<_Args...>&& __tuple)
{
typedef typename _Build_index_tuple<sizeof...(_Args)>::__type
_Indexes;
template<class _T1, class _T2>
template<typename _Tp, typename... _Args, int... _Indexes>
inline _Tp
- pair<_T1, _T2>::
- __do_cons(tuple<_Args...>&& __tuple,
- const _Index_tuple<_Indexes...>&)
+ pair<_T1, _T2>::__do_cons(tuple<_Args...>&& __tuple,
+ const _Index_tuple<_Indexes...>&)
{ return _Tp(std::forward<_Args>(get<_Indexes>(__tuple))...); }
_GLIBCXX_END_NAMESPACE_VERSION
--- /dev/null
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// NOTE: This makes use of the fact that we know how moveable
+// is implemented on pair, and also vector. If the implementation
+// changes this test may begin to fail.
+
+#include <tuple>
+
+bool test __attribute__((unused)) = true;
+
+
+// make_tuple
+#if 0
+void
+test_make_tuple()
+{
+ {
+ typedef std::tuple<int, float> tuple_type;
+ constexpr tuple_type p1 = std::make_tuple(22, 22.222);
+ }
+
+ {
+ typedef std::tuple<int, float, int> tuple_type;
+ constexpr tuple_type p1 = std::make_tuple(22, 22.222, 77799);
+ }
+}
+#endif
+
+// get
+void
+test_get()
+{
+ {
+ typedef std::tuple<int, float> tuple_type;
+ constexpr tuple_type t1 { 55, 77.77 };
+ constexpr auto var = std::get<1>(t1);
+ }
+
+ {
+ typedef std::tuple<int, float, int> tuple_type;
+ constexpr tuple_type t1 { 55, 77.77, 99 };
+ constexpr auto var = std::get<2>(t1);
+ }
+}
+
+// tuple_cat
+void
+test_tuple_cat()
+{
+ typedef std::tuple<int, float> tuple_type1;
+ typedef std::tuple<int, int, float> tuple_type2;
+
+ constexpr tuple_type1 t1 { 55, 77.77 };
+ constexpr tuple_type2 t2 { 55, 99, 77.77 };
+ constexpr auto cat1 = std::tuple_cat(t1, t2);
+}
+
+
+int
+main()
+{
+#if 0
+ test_make_tuple();
+#endif
+
+ test_get();
+
+ test_tuple_cat();
+
+ return 0;
+}