Changed occurances of "tuples::get" to "get" to verify new forwarding code in tuples.hpp

[SVN r12291]
This commit is contained in:
John Maddock
2002-01-13 12:12:48 +00:00
parent 55a83b6408
commit 2ab1b6705f

View File

@ -12,7 +12,7 @@
using namespace std; using namespace std;
using namespace boost; using namespace boost;
#if 0
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// helpers // helpers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -103,32 +103,32 @@ construction_test()
// MSVC 6.0 just cannot find get without the namespace qualifier // MSVC 6.0 just cannot find get without the namespace qualifier
tuple<int> t1; tuple<int> t1;
BOOST_TEST(tuples::get<0>(t1) == int()); BOOST_TEST(get<0>(t1) == int());
tuple<float> t2(5.5f); tuple<float> t2(5.5f);
BOOST_TEST(tuples::get<0>(t2) > 5.4f && tuples::get<0>(t2) < 5.6f); BOOST_TEST(get<0>(t2) > 5.4f && get<0>(t2) < 5.6f);
tuple<foo> t3(foo(12)); tuple<foo> t3(foo(12));
BOOST_TEST(tuples::get<0>(t3) == foo(12)); BOOST_TEST(get<0>(t3) == foo(12));
tuple<double> t4(t2); tuple<double> t4(t2);
BOOST_TEST(tuples::get<0>(t4) > 5.4 && tuples::get<0>(t4) < 5.6); BOOST_TEST(get<0>(t4) > 5.4 && get<0>(t4) < 5.6);
tuple<int, float> t5; tuple<int, float> t5;
BOOST_TEST(tuples::get<0>(t5) == int()); BOOST_TEST(get<0>(t5) == int());
BOOST_TEST(tuples::get<1>(t5) == float()); BOOST_TEST(get<1>(t5) == float());
tuple<int, float> t6(12, 5.5f); tuple<int, float> t6(12, 5.5f);
BOOST_TEST(tuples::get<0>(t6) == 12); BOOST_TEST(get<0>(t6) == 12);
BOOST_TEST(tuples::get<1>(t6) > 5.4f && tuples::get<1>(t6) < 5.6f); BOOST_TEST(get<1>(t6) > 5.4f && get<1>(t6) < 5.6f);
tuple<int, float> t7(t6); tuple<int, float> t7(t6);
BOOST_TEST(tuples::get<0>(t7) == 12); BOOST_TEST(get<0>(t7) == 12);
BOOST_TEST(tuples::get<1>(t7) > 5.4f && tuples::get<1>(t7) < 5.6f); BOOST_TEST(get<1>(t7) > 5.4f && get<1>(t7) < 5.6f);
tuple<long, double> t8(t6); tuple<long, double> t8(t6);
BOOST_TEST(tuples::get<0>(t8) == 12); BOOST_TEST(get<0>(t8) == 12);
BOOST_TEST(tuples::get<1>(t8) > 5.4f && tuples::get<1>(t8) < 5.6f); BOOST_TEST(get<1>(t8) > 5.4f && get<1>(t8) < 5.6f);
dummy( dummy(
tuple<no_def_constructor, no_def_constructor, no_def_constructor>( tuple<no_def_constructor, no_def_constructor, no_def_constructor>(
@ -156,7 +156,6 @@ construction_test()
// dummy(tuple<double&>(dd+3.14)); // should fail, // dummy(tuple<double&>(dd+3.14)); // should fail,
// // temporary to non-const reference // // temporary to non-const reference
} }
@ -172,30 +171,30 @@ void element_access_test()
tuple<int, double&, const A&, int> t(1, d, a, 2); tuple<int, double&, const A&, int> t(1, d, a, 2);
const tuple<int, double&, const A, int> ct = t; const tuple<int, double&, const A, int> ct = t;
int i = tuples::get<0>(t); int i = get<0>(t);
int i2 = tuples::get<3>(t); int i2 = get<3>(t);
BOOST_TEST(i == 1 && i2 == 2); BOOST_TEST(i == 1 && i2 == 2);
int j = tuples::get<0>(ct); int j = get<0>(ct);
BOOST_TEST(j == 1); BOOST_TEST(j == 1);
tuples::get<0>(t) = 5; get<0>(t) = 5;
BOOST_TEST(t.head == 5); BOOST_TEST(t.head == 5);
// tuples::get<0>(ct) = 5; // can't assign to const // get<0>(ct) = 5; // can't assign to const
double e = tuples::get<1>(t); double e = get<1>(t);
BOOST_TEST(e > 2.69 && e < 2.71); BOOST_TEST(e > 2.69 && e < 2.71);
tuples::get<1>(t) = 3.14+i; get<1>(t) = 3.14+i;
BOOST_TEST(tuples::get<1>(t) > 4.13 && tuples::get<1>(t) < 4.15); BOOST_TEST(get<1>(t) > 4.13 && get<1>(t) < 4.15);
// tuples::get<4>(t) = A(); // can't assign to const // get<4>(t) = A(); // can't assign to const
// dummy(tuples::get<5>(ct)); // illegal index // dummy(get<5>(ct)); // illegal index
++tuples::get<0>(t); ++get<0>(t);
BOOST_TEST(tuples::get<0>(t) == 6); BOOST_TEST(get<0>(t) == 6);
dummy(i); dummy(i2); dummy(j); dummy(e); // avoid warns for unused variables dummy(i); dummy(i2); dummy(j); dummy(e); // avoid warns for unused variables
#else #else
@ -203,27 +202,27 @@ void element_access_test()
A a; A a;
tuple<int, double, const A, int> t(1, d, a, 2); tuple<int, double, const A, int> t(1, d, a, 2);
int i = tuples::get<0>(t); int i = get<0>(t);
int i2 = tuples::get<3>(t); int i2 = get<3>(t);
BOOST_TEST(i == 1 && i2 == 2); BOOST_TEST(i == 1 && i2 == 2);
tuples::get<0>(t) = 5; get<0>(t) = 5;
BOOST_TEST(t.head == 5); BOOST_TEST(t.head == 5);
// tuples::get<0>(ct) = 5; // can't assign to const // get<0>(ct) = 5; // can't assign to const
double e = tuples::get<1>(t); double e = get<1>(t);
BOOST_TEST(e > 2.69 && e < 2.71); BOOST_TEST(e > 2.69 && e < 2.71);
tuples::get<1>(t) = 3.14+i; get<1>(t) = 3.14+i;
BOOST_TEST(tuples::get<1>(t) > 4.13 && tuples::get<1>(t) < 4.15); BOOST_TEST(get<1>(t) > 4.13 && get<1>(t) < 4.15);
// tuples::get<4>(t) = A(); // can't assign to const // get<4>(t) = A(); // can't assign to const
// dummy(tuples::get<5>(ct)); // illegal index // dummy(get<5>(ct)); // illegal index
++tuples::get<0>(t); ++get<0>(t);
BOOST_TEST(tuples::get<0>(t) == 6); BOOST_TEST(get<0>(t) == 6);
dummy(i); dummy(i2); dummy(e); // avoid warns for unused variables dummy(i); dummy(i2); dummy(e); // avoid warns for unused variables
#endif #endif
@ -242,13 +241,13 @@ copy_test()
tuple<int, char> t1(4, 'a'); tuple<int, char> t1(4, 'a');
tuple<int, char> t2(5, 'b'); tuple<int, char> t2(5, 'b');
t2 = t1; t2 = t1;
BOOST_TEST(tuples::get<0>(t1) == tuples::get<0>(t2)); BOOST_TEST(get<0>(t1) == get<0>(t2));
BOOST_TEST(tuples::get<1>(t1) == tuples::get<1>(t2)); BOOST_TEST(get<1>(t1) == get<1>(t2));
tuple<long, std::string> t3(2, "a"); tuple<long, std::string> t3(2, "a");
t3 = t1; t3 = t1;
BOOST_TEST((double)tuples::get<0>(t1) == tuples::get<0>(t3)); BOOST_TEST((double)get<0>(t1) == get<0>(t3));
BOOST_TEST(tuples::get<1>(t1) == tuples::get<1>(t3)[0]); BOOST_TEST(get<1>(t1) == get<1>(t3)[0]);
// testing copy and assignment with implicit conversions between elements // testing copy and assignment with implicit conversions between elements
// testing tie // testing tie
@ -269,15 +268,15 @@ void
mutate_test() mutate_test()
{ {
tuple<int, float, bool, foo> t1(5, 12.2f, true, foo(4)); tuple<int, float, bool, foo> t1(5, 12.2f, true, foo(4));
tuples::get<0>(t1) = 6; get<0>(t1) = 6;
tuples::get<1>(t1) = 2.2f; get<1>(t1) = 2.2f;
tuples::get<2>(t1) = false; get<2>(t1) = false;
tuples::get<3>(t1) = foo(5); get<3>(t1) = foo(5);
BOOST_TEST(tuples::get<0>(t1) == 6); BOOST_TEST(get<0>(t1) == 6);
BOOST_TEST(tuples::get<1>(t1) > 2.1f && tuples::get<1>(t1) < 2.3f); BOOST_TEST(get<1>(t1) > 2.1f && get<1>(t1) < 2.3f);
BOOST_TEST(tuples::get<2>(t1) == false); BOOST_TEST(get<2>(t1) == false);
BOOST_TEST(tuples::get<3>(t1) == foo(5)); BOOST_TEST(get<3>(t1) == foo(5));
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -288,13 +287,13 @@ void
make_tuple_test() make_tuple_test()
{ {
tuple<int, char> t1 = make_tuple(5, 'a'); tuple<int, char> t1 = make_tuple(5, 'a');
BOOST_TEST(tuples::get<0>(t1) == 5); BOOST_TEST(get<0>(t1) == 5);
BOOST_TEST(tuples::get<1>(t1) == 'a'); BOOST_TEST(get<1>(t1) == 'a');
tuple<int, std::string> t2; tuple<int, std::string> t2;
t2 = make_tuple((short int)2, std::string("Hi")); t2 = make_tuple((short int)2, std::string("Hi"));
BOOST_TEST(tuples::get<0>(t2) == 2); BOOST_TEST(get<0>(t2) == 2);
BOOST_TEST(tuples::get<1>(t2) == "Hi"); BOOST_TEST(get<1>(t2) == "Hi");
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
@ -447,8 +446,8 @@ void cons_test()
void const_tuple_test() void const_tuple_test()
{ {
const tuple<int, float> t1(5, 3.3f); const tuple<int, float> t1(5, 3.3f);
BOOST_TEST(tuples::get<0>(t1) == 5); BOOST_TEST(get<0>(t1) == 5);
BOOST_TEST(tuples::get<1>(t1) == 3.3f); BOOST_TEST(get<1>(t1) == 3.3f);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -491,3 +490,10 @@ int test_main(int, char *[]) {
tuple_length_test(); tuple_length_test();
return 0; return 0;
} }
#endif