1 //-----------------------------------------------------------------------------
2 // boost-libs variant/test/test6.cpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
5 //
6 // Copyright (c) 2003
7 // Eric Friedman, Itay Maman
8 //
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
12 
13 #include "boost/core/lightweight_test.hpp"
14 #include "boost/variant.hpp"
15 
16 #include <iostream>
17 
18 #include "jobs.h"
19 
20 
21 //Just Another Class
22 struct jac
23 {
jacjac24    jac() { }
jacjac25    jac(int ) { }
jacjac26    jac(const char* ) { }
27 };
28 
operator <<(std::ostream & out,const jac &)29 std::ostream& operator<<(std::ostream& out, const jac& )
30 {
31    out << "jac ";
32    return out;
33 }
34 
35 
run()36 void run()
37 {
38    using boost::variant;
39 
40    variant<jac, int, double*, const double*> v1;
41    variant<int, char, double*, const double*, char*> v2;
42 
43    v1 = v2;
44 
45    verify(v1, spec<int>());
46    verify(v2, spec<int>());
47 
48    verify_not(v1, spec<jac>());
49    verify_not(v1, spec<double*>());
50    verify_not(v1, spec<const double*>());
51 
52    verify_not(v2, spec<char>());
53    verify_not(v2, spec<double*>());
54    verify_not(v2, spec<const double*>());
55    verify_not(v2, spec<char*>());
56 
57 
58    variant<jac, const double*> v3;
59    variant<int, unsigned char, double*> v4;
60 
61    v3 = v4;
62    verify(v3, spec<jac>());
63    verify(v4, spec<int>());
64    verify_not(v4, spec<unsigned char>());
65 }
66 
67 
68 
main()69 int main()
70 {
71    run();
72    return boost::report_errors();
73 }
74 
75