]>
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 #include "boost/tuple/tuple.hpp"
20 #include "boost/core/lightweight_test.hpp"
25 using namespace boost
;
26 using namespace boost::tuples
;
29 template<class T
> void dummy(const T
&) {}
31 class A
{}; class B
{}; class C
{};
33 // A non-copyable class
35 no_copy(const no_copy
&) {}
43 tuple
<no_copy
> v1
; // should faild
49 tuple
<char[10]> v3
; // should fail, arrays must be stored as references
52 // a class without a public default constructor
53 class no_def_constructor
{
54 no_def_constructor() {}
56 no_def_constructor(std::string
) {} // can be constructed with a string
62 dummy(tuple
<no_def_constructor
, no_def_constructor
, no_def_constructor
>());
69 // testing default values
71 dummy(tuple
<double&>()); // should fail, not defaults for references
72 dummy(tuple
<const double&>()); // likewise
77 dummy(tuple
<double&>(dd
+3.14)); // should fail, temporary to non-const reference
83 // make_tuple ------------------------------------------
88 std::make_pair("Doesn't","Work"); // fails
90 // make_tuple("Does", "Work"); // this should work
95 // - testing element access
101 tuple
<int, double&, const A
&> t(1, d
, a
);
102 const tuple
<int, double&, const A
> ct
= t
;
105 get
<0>(ct
) = 5; // can't assign to const
109 get
<4>(t
) = A(); // can't assign to const
112 dummy(get
<5>(ct
)); // illegal index
116 // testing copy and assignment with implicit conversions between elements
120 class BB
: public AA
{};
121 struct CC
{ CC() {} CC(const BB
& b
) {} };
122 struct DD
{ operator CC() const { return CC(); }; };
125 tuple
<char, BB
*, BB
, DD
> t
;
127 tuple
<char, char> aaa
;
128 tuple
<int, int> bbb(aaa
);
130 // tuple<int, AA*, CC, CC> a = t;
136 // testing assignment from std::pair
139 tuple
<int, int, float> a
;
141 a
= std::make_pair(1, 2); // should fail, tuple is of length 3, not 2
149 // --------------------------------
150 // ----------------------------
161 return boost::report_errors();