2002-01-29 14:13:10 +00:00
|
|
|
/* Copyright (C) 2002
|
|
|
|
* Housemarque Oy
|
|
|
|
* http://www.housemarque.com
|
|
|
|
*
|
|
|
|
* Permission to copy, use, modify, sell and distribute this software is
|
|
|
|
* granted provided this copyright notice appears in all copies. This
|
|
|
|
* software is provided "as is" without express or implied warranty, and
|
|
|
|
* with no claim as to its suitability for any purpose.
|
|
|
|
*
|
|
|
|
* See http://www.boost.org for most recent version.
|
|
|
|
*/
|
2002-01-29 08:37:56 +00:00
|
|
|
|
2002-01-29 14:30:09 +00:00
|
|
|
/* This example demonstrates the usage of preprocessor lists for generating C++ code. */
|
2002-01-29 12:24:55 +00:00
|
|
|
|
2002-01-30 10:22:13 +00:00
|
|
|
#include <boost/preprocessor/list/for_each_product.hpp>
|
|
|
|
#include <boost/preprocessor/list/at.hpp>
|
2002-01-29 08:37:56 +00:00
|
|
|
#include <boost/preprocessor/tuple/to_list.hpp>
|
2002-01-29 12:24:55 +00:00
|
|
|
#include <boost/preprocessor/empty.hpp>
|
2002-01-29 08:37:56 +00:00
|
|
|
|
2002-01-29 14:30:09 +00:00
|
|
|
/* List of integral types. (Strictly speaking, wchar_t should be on the list.) */
|
2002-01-29 08:37:56 +00:00
|
|
|
#define INTEGRAL_TYPES\
|
2002-01-29 12:24:55 +00:00
|
|
|
BOOST_PP_TUPLE_TO_LIST(9,(char, signed char, unsigned char, short, unsigned short, int, unsigned, long, unsigned long))
|
2002-01-29 08:37:56 +00:00
|
|
|
|
2002-01-30 10:22:13 +00:00
|
|
|
/* List of invokeable cv-qualifiers. */
|
|
|
|
#define CV_QUALIFIERS\
|
|
|
|
BOOST_PP_TUPLE_TO_LIST(4,(BOOST_PP_EMPTY, const BOOST_PP_EMPTY, volatile BOOST_PP_EMPTY, const volatile BOOST_PP_EMPTY))
|
|
|
|
|
2002-01-29 14:30:09 +00:00
|
|
|
/* Template for testing whether a type is an integral type. */
|
2002-01-29 12:24:55 +00:00
|
|
|
template<class T> struct is_integral {enum {value = false};};
|
2002-01-29 08:37:56 +00:00
|
|
|
|
2002-01-30 10:22:13 +00:00
|
|
|
/* Macro for defining a specialization of is_integral<> template. */
|
|
|
|
#define IS_INTEGRAL_SPECIALIZATION(R,_,L)\
|
|
|
|
template<> struct is_integral<BOOST_PP_LIST_AT(L,1)() BOOST_PP_LIST_AT(L,0)> {enum {value = true};};
|
2002-01-29 08:37:56 +00:00
|
|
|
|
2002-01-30 10:22:13 +00:00
|
|
|
BOOST_PP_LIST_FOR_EACH_PRODUCT(IS_INTEGRAL_SPECIALIZATION,_,BOOST_PP_TUPLE_TO_LIST(2,(CV_QUALIFIERS, INTEGRAL_TYPES)))
|
2002-01-29 12:24:55 +00:00
|
|
|
#undef IS_INTEGRAL_SPECIALIZATION
|
2002-01-30 10:22:13 +00:00
|
|
|
#undef CV_QUALIFIERS
|
2002-01-29 08:37:56 +00:00
|
|
|
#undef INTEGRAL_TYPES
|