-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathvariant-main.t.hpp
91 lines (66 loc) · 2.29 KB
/
variant-main.t.hpp
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2016-2018 by Martin Moene
//
// https://github.com/martinmoene/variant-lite
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#pragma once
#ifndef TEST_VARIANT_LITE_H_INCLUDED
#define TEST_VARIANT_LITE_H_INCLUDED
#include "nonstd/variant.hpp"
// Compiler warning suppression for usage of lest:
#ifdef __clang__
# pragma clang diagnostic ignored "-Wstring-conversion"
# pragma clang diagnostic ignored "-Wunused-parameter"
# pragma clang diagnostic ignored "-Wunused-template"
# pragma clang diagnostic ignored "-Wunused-function"
# pragma clang diagnostic ignored "-Wunused-member-function"
#elif defined __GNUC__
# pragma GCC diagnostic ignored "-Wunused-parameter"
# pragma GCC diagnostic ignored "-Wunused-function"
#endif
#include <iostream>
#if variant_HAVE_STD_VARIANT
namespace lest {
template< class Head, class... Types >
inline std::ostream & operator<<( std::ostream & os, nonstd::variant<Head, Types...> const & v )
{
return os << "[variant:?]";
}
}
#else // variant_HAVE_STD_VARIANT
namespace nonstd { namespace variants {
// use oparator<< instead of to_string() overload;
// see http://stackoverflow.com/a/10651752/437272
template< class T >
inline std::ostream & operator<<( std::ostream & os, nonstd::variants::detail::TX<T> const & v )
{
return os << "[variant:tx]";
}
template< class T0, class T1, class T2, class T3, class T4, class T5, class T6 >
inline std::ostream & operator<<( std::ostream & os, nonstd::variant<T0, T1, T2, T3, T4, T5, T6> const & v )
{
os << "[variant:";
switch( v.index() )
{
case 0: os << get<0>( v ); break;
case 1: os << get<1>( v ); break;
case 2: os << get<2>( v ); break;
case 3: os << get<3>( v ); break;
case 4: os << get<4>( v ); break;
case 5: os << get<5>( v ); break;
case 6: os << get<6>( v ); break;
default: os << "unexpected index";
}
return os << "]";
}
}}
namespace lest {
using ::nonstd::variants::operator<<;
} // namespace lest
#endif // variant_HAVE_STD_VARIANT
#include "lest_cpp03.hpp"
extern lest::tests & specification();
#define CASE( name ) lest_CASE( specification(), name )
#endif // TEST_VARIANT_LITE_H_INCLUDED
// end of file