]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | # /* Copyright (C) 2002 |
2 | # * Housemarque Oy | |
3 | # * http://www.housemarque.com | |
4 | # * | |
5 | # * Distributed under the Boost Software License, Version 1.0. (See | |
6 | # * accompanying file LICENSE_1_0.txt or copy at | |
7 | # * http://www.boost.org/LICENSE_1_0.txt) | |
8 | # */ | |
9 | # | |
10 | # /* Revised by Paul Mensonides (2002) */ | |
11 | # | |
12 | # /* See http://www.boost.org for most recent version. */ | |
13 | # | |
14 | # /* This example demonstrates the usage of preprocessor lists for generating C++ code. */ | |
15 | # | |
16 | # include <boost/preprocessor/facilities/empty.hpp> | |
17 | # include <boost/preprocessor/list/at.hpp> | |
18 | # include <boost/preprocessor/list/for_each_product.hpp> | |
19 | # include <boost/preprocessor/tuple/elem.hpp> | |
20 | # include <boost/preprocessor/tuple/to_list.hpp> | |
21 | # | |
22 | # /* List of integral types. (Strictly speaking, wchar_t should be on the list.) */ | |
23 | # define INTEGRAL_TYPES \ | |
24 | BOOST_PP_TUPLE_TO_LIST( \ | |
25 | 9, (char, signed char, unsigned char, short, unsigned short, int, unsigned, long, unsigned long) \ | |
26 | ) \ | |
27 | /**/ | |
28 | # | |
29 | # /* List of invokeable cv-qualifiers */ | |
30 | # define CV_QUALIFIERS \ | |
31 | BOOST_PP_TUPLE_TO_LIST( \ | |
32 | 4, (BOOST_PP_EMPTY, const BOOST_PP_EMPTY, volatile BOOST_PP_EMPTY, const volatile BOOST_PP_EMPTY) \ | |
33 | ) \ | |
34 | /**/ | |
35 | # | |
36 | # /* Template for testing whether a type is an integral type. */ | |
37 | ||
38 | template<class T> struct is_integral { | |
39 | enum { value = false }; | |
40 | }; | |
41 | ||
42 | # /* Macro for defining a specialization of is_integral<> template. */ | |
43 | # define IS_INTEGRAL_SPECIALIZATION(R, L) \ | |
44 | template<> struct is_integral<BOOST_PP_TUPLE_ELEM(2, 0, L)() BOOST_PP_TUPLE_ELEM(2, 1, L)> { \ | |
45 | enum { value = true }; \ | |
46 | }; \ | |
47 | /**/ | |
48 | ||
49 | BOOST_PP_LIST_FOR_EACH_PRODUCT(IS_INTEGRAL_SPECIALIZATION, 2, (CV_QUALIFIERS, INTEGRAL_TYPES)) |