tuple (pack_arguments): Rename to forward_as_tuple and simplify, per US 98 and US 99.
2010-08-06 Paolo Carlini <paolo.carlini@oracle.com> * include/std/tuple (pack_arguments): Rename to forward_as_tuple and simplify, per US 98 and US 99. * testsuite/20_util/tuple/creation_functions/pack_arguments.cc: Rename to... * testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc: ... this, adjust. * testsuite/20_util/pair/piecewise.cc: Adjust. From-SVN: r162948
This commit is contained in:
parent
f25496f352
commit
00e9a94486
|
@ -1,3 +1,13 @@
|
||||||
|
2010-08-06 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
* include/std/tuple (pack_arguments): Rename to forward_as_tuple
|
||||||
|
and simplify, per US 98 and US 99.
|
||||||
|
* testsuite/20_util/tuple/creation_functions/pack_arguments.cc:
|
||||||
|
Rename to...
|
||||||
|
* testsuite/20_util/tuple/creation_functions/forward_as_tuple.cc:
|
||||||
|
... this, adjust.
|
||||||
|
* testsuite/20_util/pair/piecewise.cc: Adjust.
|
||||||
|
|
||||||
2010-08-06 Paolo Carlini <paolo.carlini@oracle.com>
|
2010-08-06 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
* include/std/tuple (begin, end): Remove per GB 87.
|
* include/std/tuple (begin, end): Remove per GB 87.
|
||||||
|
|
|
@ -549,27 +549,10 @@ namespace std
|
||||||
return __result_type(std::forward<_Elements>(__args)...);
|
return __result_type(std::forward<_Elements>(__args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _Tp, bool = is_array<_Tp>::value>
|
|
||||||
struct __pa_add_rvalue_reference_helper
|
|
||||||
{ typedef typename std::add_rvalue_reference<_Tp>::type __type; };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __pa_add_rvalue_reference_helper<_Tp, true>
|
|
||||||
{ typedef _Tp& __type; };
|
|
||||||
|
|
||||||
template<typename _Tp>
|
|
||||||
struct __pa_add_rvalue_reference
|
|
||||||
: public __pa_add_rvalue_reference_helper<_Tp>
|
|
||||||
{ };
|
|
||||||
|
|
||||||
template<typename... _Elements>
|
template<typename... _Elements>
|
||||||
inline tuple<typename __pa_add_rvalue_reference<_Elements>::__type...>
|
inline tuple<_Elements&&...>
|
||||||
pack_arguments(_Elements&&... __args)
|
forward_as_tuple(_Elements&&... __args)
|
||||||
{
|
{ return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
|
||||||
typedef tuple<typename __pa_add_rvalue_reference<_Elements>::__type...>
|
|
||||||
__result_type;
|
|
||||||
return __result_type(std::forward<_Elements>(__args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<std::size_t...> struct __index_holder { };
|
template<std::size_t...> struct __index_holder { };
|
||||||
|
|
||||||
|
|
|
@ -70,21 +70,21 @@ void test01()
|
||||||
bool test __attribute__((unused)) = true;
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::pair<type_one, type_zero> pp0(std::piecewise_construct_t(),
|
std::pair<type_one, type_zero> pp0(std::piecewise_construct_t(),
|
||||||
std::pack_arguments(-3),
|
std::forward_as_tuple(-3),
|
||||||
std::pack_arguments());
|
std::forward_as_tuple());
|
||||||
VERIFY( pp0.first.get() == -3 );
|
VERIFY( pp0.first.get() == -3 );
|
||||||
VERIFY( pp0.second.get() == 757 );
|
VERIFY( pp0.second.get() == 757 );
|
||||||
|
|
||||||
std::pair<type_one, type_two> pp1(std::piecewise_construct_t(),
|
std::pair<type_one, type_two> pp1(std::piecewise_construct_t(),
|
||||||
std::pack_arguments(6),
|
std::forward_as_tuple(6),
|
||||||
std::pack_arguments(5, 4));
|
std::forward_as_tuple(5, 4));
|
||||||
VERIFY( pp1.first.get() == 6 );
|
VERIFY( pp1.first.get() == 6 );
|
||||||
VERIFY( pp1.second.get1() == 5 );
|
VERIFY( pp1.second.get1() == 5 );
|
||||||
VERIFY( pp1.second.get2() == 4 );
|
VERIFY( pp1.second.get2() == 4 );
|
||||||
|
|
||||||
std::pair<type_two, type_two> pp2(std::piecewise_construct_t(),
|
std::pair<type_two, type_two> pp2(std::piecewise_construct_t(),
|
||||||
std::pack_arguments(2, 1),
|
std::forward_as_tuple(2, 1),
|
||||||
std::pack_arguments(-1, -3));
|
std::forward_as_tuple(-1, -3));
|
||||||
VERIFY( pp2.first.get1() == 2 );
|
VERIFY( pp2.first.get1() == 2 );
|
||||||
VERIFY( pp2.first.get2() == 1 );
|
VERIFY( pp2.first.get2() == 1 );
|
||||||
VERIFY( pp2.second.get1() == -1 );
|
VERIFY( pp2.second.get1() == -1 );
|
||||||
|
|
|
@ -30,16 +30,16 @@ test01()
|
||||||
{
|
{
|
||||||
bool test __attribute__((unused)) = true;
|
bool test __attribute__((unused)) = true;
|
||||||
|
|
||||||
std::pack_arguments();
|
std::forward_as_tuple();
|
||||||
|
|
||||||
VERIFY( std::get<0>(std::pack_arguments(-1)) == -1 );
|
VERIFY( std::get<0>(std::forward_as_tuple(-1)) == -1 );
|
||||||
VERIFY( (std::is_same<decltype(std::pack_arguments(-1)),
|
VERIFY( (std::is_same<decltype(std::forward_as_tuple(-1)),
|
||||||
std::tuple<int&&>>::value) );
|
std::tuple<int&&>>::value) );
|
||||||
|
|
||||||
const int i1 = 1;
|
const int i1 = 1;
|
||||||
const int i2 = 2;
|
const int i2 = 2;
|
||||||
const double d1 = 4.0;
|
const double d1 = 4.0;
|
||||||
auto t1 = std::pack_arguments(i1, i2, d1);
|
auto t1 = std::forward_as_tuple(i1, i2, d1);
|
||||||
VERIFY( (std::is_same<decltype(t1), std::tuple<const int&,
|
VERIFY( (std::is_same<decltype(t1), std::tuple<const int&,
|
||||||
const int&, const double&>>::value) );
|
const int&, const double&>>::value) );
|
||||||
VERIFY( std::get<0>(t1) == i1 );
|
VERIFY( std::get<0>(t1) == i1 );
|
||||||
|
@ -48,7 +48,7 @@ test01()
|
||||||
|
|
||||||
typedef const int a_type1[3];
|
typedef const int a_type1[3];
|
||||||
a_type1 a1 = { -1, 1, 2 };
|
a_type1 a1 = { -1, 1, 2 };
|
||||||
auto t2 = std::pack_arguments(a1);
|
auto t2 = std::forward_as_tuple(a1);
|
||||||
VERIFY( (std::is_same<decltype(t2), std::tuple<a_type1&>>::value) );
|
VERIFY( (std::is_same<decltype(t2), std::tuple<a_type1&>>::value) );
|
||||||
VERIFY( std::get<0>(t2)[0] == a1[0] );
|
VERIFY( std::get<0>(t2)[0] == a1[0] );
|
||||||
VERIFY( std::get<0>(t2)[1] == a1[1] );
|
VERIFY( std::get<0>(t2)[1] == a1[1] );
|
||||||
|
@ -57,7 +57,7 @@ test01()
|
||||||
typedef int a_type2[2];
|
typedef int a_type2[2];
|
||||||
a_type2 a2 = { 2, -2 };
|
a_type2 a2 = { 2, -2 };
|
||||||
volatile int i4 = 1;
|
volatile int i4 = 1;
|
||||||
auto t3 = std::pack_arguments(a2, i4);
|
auto t3 = std::forward_as_tuple(a2, i4);
|
||||||
VERIFY( (std::is_same<decltype(t3), std::tuple<a_type2&,
|
VERIFY( (std::is_same<decltype(t3), std::tuple<a_type2&,
|
||||||
volatile int&>>::value) );
|
volatile int&>>::value) );
|
||||||
VERIFY( std::get<0>(t3)[0] == a2[0] );
|
VERIFY( std::get<0>(t3)[0] == a2[0] );
|
Loading…
Reference in New Issue