Brian Silverman | f27e085 | 2018-08-04 23:56:45 -0700 | [diff] [blame^] | 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 lists and BOOST_PP_LIST_FOR_EACH(). */ |
| 15 | # |
| 16 | # include <iostream> |
| 17 | # include <typeinfo> |
| 18 | # |
| 19 | # include <boost/preprocessor/list/for_each.hpp> |
| 20 | # include <boost/preprocessor/tuple/to_list.hpp> |
| 21 | # |
| 22 | # /* List of built-in types. (Strictly speaking wchar_t should be on the list.) */ |
| 23 | # |
| 24 | # define BUILTIN_TYPES \ |
| 25 | BOOST_PP_TUPLE_TO_LIST( \ |
| 26 | 13, \ |
| 27 | ( \ |
| 28 | bool, \ |
| 29 | char, signed char, unsigned char, \ |
| 30 | unsigned short, short, \ |
| 31 | int, unsigned, \ |
| 32 | long, unsigned long, \ |
| 33 | float, \ |
| 34 | double, long double \ |
| 35 | ) \ |
| 36 | ) \ |
| 37 | /**/ |
| 38 | # |
| 39 | # define CATCH(R, _, T) \ |
| 40 | catch (T t) { \ |
| 41 | std::cerr << "Caught an " << typeid(t).name() << " = " << t; \ |
| 42 | } \ |
| 43 | /**/ |
| 44 | |
| 45 | int main() { |
| 46 | try { |
| 47 | throw 10; |
| 48 | } |
| 49 | BOOST_PP_LIST_FOR_EACH(CATCH, _, BUILTIN_TYPES) |
| 50 | return 0; |
| 51 | } |