]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/tuple/test/another_tuple_test_bench.cpp
1 // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 // For more information, see http://www.boost.org
10 // another_test_bench.cpp --------------------------------
12 // This file has various tests to see that things that shouldn't
13 // compile, don't compile.
15 // Defining any of E1 to E5 or E7 to E11 opens some illegal code that
16 // should cause the compliation to fail.
18 #define BOOST_INCLUDE_MAIN // for testing, include rather than link
19 #include <boost/test/test_tools.hpp> // see "Header Implementation Option"
21 #include "boost/tuple/tuple.hpp"
26 using namespace boost
;
27 using namespace boost::tuples
;
30 template<class T
> void dummy(const T
&) {}
32 class A
{}; class B
{}; class C
{};
34 // A non-copyable class
36 no_copy(const no_copy
&) {}
44 tuple
<no_copy
> v1
; // should faild
50 tuple
<char[10]> v3
; // should fail, arrays must be stored as references
53 // a class without a public default constructor
54 class no_def_constructor
{
55 no_def_constructor() {}
57 no_def_constructor(std::string
) {} // can be constructed with a string
63 dummy(tuple
<no_def_constructor
, no_def_constructor
, no_def_constructor
>());
70 // testing default values
72 dummy(tuple
<double&>()); // should fail, not defaults for references
73 dummy(tuple
<const double&>()); // likewise
78 dummy(tuple
<double&>(dd
+3.14)); // should fail, temporary to non-const reference
84 // make_tuple ------------------------------------------
89 std::make_pair("Doesn't","Work"); // fails
91 // make_tuple("Does", "Work"); // this should work
96 // - testing element access
102 tuple
<int, double&, const A
&> t(1, d
, a
);
103 const tuple
<int, double&, const A
> ct
= t
;
106 get
<0>(ct
) = 5; // can't assign to const
110 get
<4>(t
) = A(); // can't assign to const
113 dummy(get
<5>(ct
)); // illegal index
117 // testing copy and assignment with implicit conversions between elements
121 class BB
: public AA
{};
122 struct CC
{ CC() {} CC(const BB
& b
) {} };
123 struct DD
{ operator CC() const { return CC(); }; };
126 tuple
<char, BB
*, BB
, DD
> t
;
128 tuple
<char, char> aaa
;
129 tuple
<int, int> bbb(aaa
);
131 // tuple<int, AA*, CC, CC> a = t;
137 // testing assignment from std::pair
140 tuple
<int, int, float> a
;
142 a
= std::make_pair(1, 2); // should fail, tuple is of length 3, not 2
150 // --------------------------------
151 // ----------------------------
152 int test_main(int, char *[]) {