/
main.cpp
138 lines (121 loc) · 4.42 KB
/
main.cpp
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// Copyright Abel Sinkovics (abel@sinkovics.hu) 2011.
// 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 <metatest/to_stream.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/deque.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/set.hpp>
#include <boost/mpl/map.hpp>
#include <boost/mpl/pair.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/mpl/insert.hpp>
#include <iostream>
using boost::mpl::int_;
class custom_test_class;
class other_custom_test_class;
class defined_custom_test_class {};
class custom_test_class_with_long_name;
struct metafunction_class
{
typedef metafunction_class type;
template <class T>
struct apply : int_<13> {};
};
METATEST_DEFINE_TO_STREAM_FOR_SIMPLE_TYPE(custom_test_class)
METATEST_DEFINE_TO_STREAM_FOR_TYPE(
custom_test_class_with_long_name,
"short_name"
)
METATEST_DEFINE_TO_STREAM_FOR_SIMPLE_TYPE(metafunction_class)
template <class T>
struct cant_be_instantiated : T::doesnt_exist {};
METATEST_DEFINE_TO_STREAM_FOR_TEMPLATE(
1,
cant_be_instantiated,
"can't be instantiated"
)
int main()
{
using std::cout;
using std::endl;
using metatest::to_stream;
using boost::mpl::integral_c;
using boost::mpl::true_;
using boost::mpl::false_;
using boost::mpl::int_;
using boost::mpl::long_;
using boost::mpl::char_;
using boost::mpl::void_;
using boost::mpl::string;
using boost::mpl::vector_c;
using boost::mpl::list_c;
using boost::mpl::deque;
using boost::mpl::range_c;
using boost::mpl::vector;
using boost::mpl::_1;
using boost::mpl::apply;
using boost::mpl::lambda;
using boost::mpl::list;
using boost::mpl::set;
using boost::mpl::map;
using boost::mpl::pair;
using boost::mpl::push_front;
using boost::mpl::insert;
to_stream<other_custom_test_class>::run(cout) << endl;
to_stream<defined_custom_test_class>::run(cout) << endl;
to_stream<custom_test_class_with_long_name>::run(cout) << endl;
to_stream<cant_be_instantiated<int> >::run(cout) << endl;
to_stream<int>::run(cout) << endl;
to_stream<double>::run(cout) << endl;
to_stream<custom_test_class>::run(cout) << endl;
to_stream<const char*>::run(cout) << endl;
to_stream<char * const>::run(cout) << endl;
to_stream<double**>::run(cout) << endl;
to_stream<float* const *>::run(cout) << endl;
to_stream<long * const * const>::run(cout) << endl;
to_stream<short&>::run(cout) << endl;
to_stream<signed char[]>::run(cout) << endl;
to_stream<const char*[]>::run(cout) << endl;
to_stream<void>::run(cout) << endl;
to_stream<size_t>::run(cout) << endl;
cout << endl;
to_stream<integral_c<int, 13> >::run(cout) << endl;
to_stream<true_>::run(cout) << endl;
to_stream<int_<19> >::run(cout) << endl;
to_stream<long_<83> >::run(cout) << endl;
to_stream<char_<'\n'> >::run(cout) << endl;
to_stream<char_<'X'> >::run(cout) << endl;
to_stream<char_<'\x03'> >::run(cout) << endl;
to_stream<boost::mpl::size_t<13> >::run(cout) << endl;
to_stream<void_>::run(cout) << endl;
to_stream<string<'s'> >::run(cout) << endl;
to_stream<string<'\n'> >::run(cout) << endl;
to_stream<
map<pair<int_<1>, int_<2> >, pair<int_<3>, int_<4> > >::type
>::run(cout) << endl;
to_stream<map<>::type>::run(cout) << endl;
to_stream<set<int_<1>, int_<2>, int_<3> >::type>::run(cout) << endl;
to_stream<set<>::type>::run(cout) << endl;
to_stream<deque<int_<1>, int_<2>, int_<3> >::type>::run(cout) << endl;
to_stream<deque<>::type>::run(cout) << endl;
to_stream<list<int_<1>, int_<2>, int_<3> >::type>::run(cout) << endl;
to_stream<vector<int_<1>, int_<2>, int_<3> >::type>::run(cout) << endl;
to_stream<vector<>::type>::run(cout) << endl;
to_stream<vector_c<int, 1, 2, 3> >::run(cout) << endl;
to_stream<vector<int_<1>, int_<2>, int_<3> > >::run(cout) << endl;
to_stream<list_c<int, 1, 2, 3> >::run(cout) << endl;
to_stream<deque<int, float, char> >::run(cout) << endl;
to_stream<range_c<int, 1, 10> >::run(cout) << endl;
to_stream<vector_c<char, 'h', 'e', 'l', 'l', 'o'> >::run(cout) << endl;
to_stream<vector<> >::run(cout) << endl;
to_stream<_1>::run(cout) << endl;
to_stream<lambda<_1> >::run(cout) << endl;
to_stream<apply<metafunction_class, double> >::run(cout) << endl;
}