From 318494b610124b1fe70aa5ebe18d46a2cebf52ae Mon Sep 17 00:00:00 2001 From: Vesa Karvonen Date: Tue, 29 Jan 2002 08:37:56 +0000 Subject: [PATCH] Added a simple example on using BOOST_PP_LIST_FOR_EACH() [SVN r12541] --- example/array_arithmetic.c | 2 +- example/array_arithmetic_helpers.hpp | 2 +- example/delay.cpp | 2 +- example/is_integral.cpp | 38 ++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 example/is_integral.cpp diff --git a/example/array_arithmetic.c b/example/array_arithmetic.c index 8b88fa8..8fb8ec8 100644 --- a/example/array_arithmetic.c +++ b/example/array_arithmetic.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 +/* Copyright (C) 2002 * Housemarque Oy * http://www.housemarque.com * diff --git a/example/array_arithmetic_helpers.hpp b/example/array_arithmetic_helpers.hpp index b7bbc55..a9b9a0d 100644 --- a/example/array_arithmetic_helpers.hpp +++ b/example/array_arithmetic_helpers.hpp @@ -1,7 +1,7 @@ #ifndef BOOST_LIBS_PREPROCESSOR_EXAMPLE_ARRAY_ARITHMETIC_HELPERS_HPP #define BOOST_LIBS_PREPROCESSOR_EXAMPLE_ARRAY_ARITHMETIC_HELPERS_HPP -// Copyright (C) 2001 +// Copyright (C) 2002 // Housemarque Oy // http://www.housemarque.com // diff --git a/example/delay.cpp b/example/delay.cpp index e501fe4..6700e6d 100644 --- a/example/delay.cpp +++ b/example/delay.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2001 +// Copyright (C) 2002 // Housemarque Oy // http://www.housemarque.com // diff --git a/example/is_integral.cpp b/example/is_integral.cpp new file mode 100644 index 0000000..add855e --- /dev/null +++ b/example/is_integral.cpp @@ -0,0 +1,38 @@ +// 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. + +#include +#include + +// This is a list of integral types. Strictly speaking the following list +// does not include all integral types, because some compilers do not yet +// recognize all standard C++ integral types. +#define INTEGRAL_TYPES\ + BOOST_PP_TUPLE_TO_LIST\ + ( 9\ + , ( char, signed char, unsigned char,\ + short, unsigned short,\ + int, unsigned int,\ + long, unsigned long )\ + ) + +// This is a template for testing is a type is an integral type. +template struct is_integral {static const bool value = false;}; + +#define INTEGRAL_TYPE_SPECIALIZATION(R,_,T)\ + template<> struct is_integral {static const bool value = true;};\ + template<> struct is_integral {static const bool value = true;};\ + template<> struct is_integral {static const bool value = true;};\ + template<> struct is_integral {static const bool value = true;}; + +BOOST_PP_LIST_FOR_EACH(INTEGRAL_TYPE_SPECIALIZATION,_,INTEGRAL_TYPES) +#undef INTEGRAL_TYPE_SPECIALIZATION +#undef INTEGRAL_TYPES