Fix typo
[rofl0r-order-pp.git] / example / typelist.cpp
blob797933f8a0caec0e66ec3d39620dcbd120f20048
1 // (C) Copyright Vesa Karvonen 2004.
2 //
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE.)
6 # include <utility>
7 # include "static_assert.h"
8 # include "is_same.hpp"
9 # include "typelist.hpp"
11 // ### Testing
13 // To test our `TYPELIST'-macro, we'll first exercise the base
14 // case:
15 //<
16 using namespace typelist;
18 STATIC_ASSERT(is_same<TYPELIST(), nil>::value);
19 //>
20 // Then we'll try a list of 3-types:
21 //<
22 STATIC_ASSERT(is_same<TYPELIST((float)
23 (double)
24 (long double)),
25 cons<float,
26 cons<double,
27 cons<long double, nil> > > >::value);
28 //>
29 // Finally we'll try a list containing commas:
30 //<
31 STATIC_ASSERT
32 (is_same<TYPELIST((std::pair<signed char, unsigned char>)
33 (std::pair<signed short, unsigned short>)
34 (std::pair<signed int, unsigned int>)
35 (std::pair<signed long, unsigned long>)),
36 cons<std::pair<signed char, unsigned char>,
37 cons<std::pair<signed short, unsigned short>,
38 cons<std::pair<signed int, unsigned int>,
39 cons<std::pair<signed long, unsigned long> > > > > >::value);
40 //>
42 // \begin{exercise}
43 // How can one define a ``variadic'' template metafunction? (Hint:
44 // Consider default template arguments.)
45 // \end{exercise}