• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //-----------------------------------------------------------------------------
2 // boost-libs variant/test/test4.cpp source 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/config.hpp"
14 
15 #ifdef BOOST_MSVC
16 #pragma warning(disable:4244) // conversion from 'const int' to 'const short'
17 #endif
18 
19 #include "boost/core/lightweight_test.hpp"
20 #include "boost/variant.hpp"
21 
22 #include "jobs.h"
23 
24 #include <string>
25 
26 struct class_a;
27 
28 using boost::variant;
29 
30 typedef variant<std::string, class_a, float> var_type_1;
31 typedef variant<std::string, class_a, short> var_type_2;
32 
33 #include "class_a.h"
34 
main()35 int main()
36 {
37    using namespace boost;
38 
39    var_type_1 v1;
40    var_type_2 v2;
41 
42    v1 = class_a();
43    verify(v1, spec<class_a>(), "[V] class_a(5511)");
44 
45    verify(v2, spec<std::string>(), "[V] ");
46 
47    v2 = "abcde";
48    verify(v2, spec<std::string>(), "[V] abcde");
49 
50    v2 = v1;
51    verify(v2, spec<class_a>(), "[V] class_a(5511)");
52 
53    v2 = 5;
54    v1 = v2;
55 
56    return boost::report_errors();
57 }
58