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