| 1 | //-----------------------------------------------------------------------------
|
|---|
| 2 | // boost-libs variant/test/variant_multivisit_test.cpp source file
|
|---|
| 3 | // See http://www.boost.org for updates, documentation, and revision history.
|
|---|
| 4 | //-----------------------------------------------------------------------------
|
|---|
| 5 | //
|
|---|
| 6 | // Copyright (c) 2013
|
|---|
| 7 | // Antony Polukhin
|
|---|
| 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 | #define BOOST_VARAINT_MAX_MULTIVIZITOR_PARAMS 6
|
|---|
| 15 | #include "../../../margot/applications/common/functions/multivisitors.hpp"
|
|---|
| 16 |
|
|---|
| 17 | #include "boost/test/minimal.hpp"
|
|---|
| 18 |
|
|---|
| 19 | typedef boost::variant<char, unsigned char, signed char> variant3_t;
|
|---|
| 20 | typedef boost::variant<char, unsigned char, signed char, unsigned short> variant4_t;
|
|---|
| 21 | typedef boost::variant<char, unsigned char, signed char, unsigned short, int> variant5_t;
|
|---|
| 22 | typedef boost::variant<char, unsigned char, signed char, unsigned short, int, unsigned int> variant6_t;
|
|---|
| 23 |
|
|---|
| 24 | struct test_visitor: boost::static_visitor<> {
|
|---|
| 25 | // operators that shall not be called
|
|---|
| 26 | template <class T1, class T2, class T3>
|
|---|
| 27 | void operator()(T1, T2, T3) const
|
|---|
| 28 | {
|
|---|
| 29 | BOOST_CHECK(false);
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | template <class T1, class T2, class T3, class T4>
|
|---|
| 33 | void operator()(T1, T2, T3, T4) const
|
|---|
| 34 | {
|
|---|
| 35 | BOOST_CHECK(false);
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | template <class T1, class T2, class T3, class T4, class T5>
|
|---|
| 39 | void operator()(T1, T2, T3, T4, T5) const
|
|---|
| 40 | {
|
|---|
| 41 | BOOST_CHECK(false);
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | template <class T1, class T2, class T3, class T4, class T5, class T6>
|
|---|
| 45 | void operator()(T1, T2, T3, T4, T5, T6) const
|
|---|
| 46 | {
|
|---|
| 47 | BOOST_CHECK(false);
|
|---|
| 48 | }
|
|---|
| 49 |
|
|---|
| 50 | // operators that are OK to call
|
|---|
| 51 | void operator()(char, unsigned char, signed char) const
|
|---|
| 52 | {
|
|---|
| 53 | BOOST_CHECK(true);
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | void operator()(char, unsigned char, signed char, unsigned short) const
|
|---|
| 57 | {
|
|---|
| 58 | BOOST_CHECK(true);
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | void operator()(char, unsigned char, signed char, unsigned short, int) const
|
|---|
| 62 | {
|
|---|
| 63 | BOOST_CHECK(true);
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | void operator()(char, unsigned char, signed char, unsigned short, int, unsigned int) const
|
|---|
| 67 | {
|
|---|
| 68 | BOOST_CHECK(true);
|
|---|
| 69 | }
|
|---|
| 70 | };
|
|---|
| 71 |
|
|---|
| 72 | int test_main(int , char* [])
|
|---|
| 73 | {
|
|---|
| 74 | test_visitor v;
|
|---|
| 75 |
|
|---|
| 76 | variant3_t v_array3[] = {
|
|---|
| 77 | char(), unsigned char(), signed char()
|
|---|
| 78 | };
|
|---|
| 79 | boost::apply_visitor(v, v_array3[0], v_array3[1], v_array3[2]);
|
|---|
| 80 | boost::apply_visitor(test_visitor(), v_array3[0], v_array3[1], v_array3[2]);
|
|---|
| 81 |
|
|---|
| 82 | variant4_t v_array4[] = {
|
|---|
| 83 | char(), unsigned char(), signed char(), unsigned short()
|
|---|
| 84 | };
|
|---|
| 85 | boost::apply_visitor(v, v_array4[0], v_array4[1], v_array4[2], v_array4[3]);
|
|---|
| 86 | boost::apply_visitor(test_visitor(), v_array4[0], v_array4[1], v_array4[2], v_array4[3]);
|
|---|
| 87 |
|
|---|
| 88 | // Following test also pass, but requires many Gigabytes of RAM for compilation and compile for about 45 minutes
|
|---|
| 89 | //#define BOOST_VARIANT_MULTIVISITORS_TEST_VERY_EXTREME
|
|---|
| 90 | #ifdef BOOST_VARIANT_MULTIVISITORS_TEST_VERY_EXTREME
|
|---|
| 91 | variant5_t v_array5[] = {
|
|---|
| 92 | char(), unsigned char(), signed char(), unsigned short(), int()
|
|---|
| 93 | };
|
|---|
| 94 | boost::apply_visitor(v, v_array5[0], v_array5[1], v_array5[2], v_array5[3], v_array5[4]);
|
|---|
| 95 | boost::apply_visitor(test_visitor(), v_array5[0], v_array5[1], v_array5[2], v_array5[3], v_array5[4]);
|
|---|
| 96 |
|
|---|
| 97 | variant6_t v_array6[] = {
|
|---|
| 98 | char(), unsigned char(), signed char(), unsigned short(), int(), unsigned int()
|
|---|
| 99 | };
|
|---|
| 100 | boost::apply_visitor(v, v_array6[0], v_array6[1], v_array6[2], v_array6[3], v_array6[4], v_array6[5]);
|
|---|
| 101 | boost::apply_visitor(test_visitor(), v_array6[0], v_array6[1], v_array6[2], v_array6[3], v_array6[4], v_array6[5]);
|
|---|
| 102 | #endif
|
|---|
| 103 |
|
|---|
| 104 | return boost::exit_success;
|
|---|
| 105 | }
|
|---|