1// Copyright (C) 2010 Edward Diener 2// Use, modification and distribution are subject to the 3// Boost Software License, Version 1.0. (See accompanying file 4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6// See http://www.boost.org/libs/config for most recent version. 7 8// MACRO: BOOST_NO_CXX11_VARIADIC_MACROS 9// TITLE: C++0x variadic macros unavailable 10// DESCRIPTION: The compiler does not support C++0x variadic macros 11 12// This is a simple test 13 14#define TEST_VARIADIC_MACRO_SIMPLE(avalue,...) __VA_ARGS__ 15 16/* 17 18 This is a more complicated test, which Steve Watanabe graciously 19 supplied, when I asked if it were possible to strip the parantheses 20 from a macro argument. I have changed the names somewhat to prevent 21 any common clashes with other macros in the config testing suite 22 by prepending to each macro name TEST_VARIADIC_MACRO_. 23 24 You may find this test overdone and may want to remove it. 25 26*/ 27 28#define TEST_VARIADIC_MACRO_CAT(x, y) TEST_VARIADIC_MACRO_CAT_I(x, y) 29#define TEST_VARIADIC_MACRO_CAT_I(x, y) x ## y 30 31#define TEST_VARIADIC_MACRO_APPLY(macro, args) TEST_VARIADIC_MACRO_APPLY_I(macro, args) 32#define TEST_VARIADIC_MACRO_APPLY_I(macro, args) macro args 33 34#define TEST_VARIADIC_MACRO_STRIP_PARENS(x) TEST_VARIADIC_MACRO_EVAL((TEST_VARIADIC_MACRO_STRIP_PARENS_I x), x) 35#define TEST_VARIADIC_MACRO_STRIP_PARENS_I(...) 1,1 36 37#define TEST_VARIADIC_MACRO_EVAL(test, x) TEST_VARIADIC_MACRO_EVAL_I(test, x) 38#define TEST_VARIADIC_MACRO_EVAL_I(test, x) TEST_VARIADIC_MACRO_MAYBE_STRIP_PARENS(TEST_VARIADIC_MACRO_TEST_ARITY test, x) 39 40#define TEST_VARIADIC_MACRO_TEST_ARITY(...) TEST_VARIADIC_MACRO_APPLY(TEST_VARIADIC_MACRO_TEST_ARITY_I, (__VA_ARGS__, 2, 1)) 41#define TEST_VARIADIC_MACRO_TEST_ARITY_I(a,b,c,...) c 42 43#define TEST_VARIADIC_MACRO_MAYBE_STRIP_PARENS(cond, x) TEST_VARIADIC_MACRO_MAYBE_STRIP_PARENS_I(cond, x) 44#define TEST_VARIADIC_MACRO_MAYBE_STRIP_PARENS_I(cond, x) TEST_VARIADIC_MACRO_CAT(TEST_VARIADIC_MACRO_MAYBE_STRIP_PARENS_, cond)(x) 45 46#define TEST_VARIADIC_MACRO_MAYBE_STRIP_PARENS_1(x) x 47#define TEST_VARIADIC_MACRO_MAYBE_STRIP_PARENS_2(x) TEST_VARIADIC_MACRO_APPLY(TEST_VARIADIC_MACRO_MAYBE_STRIP_PARENS_2_I, x) 48#define TEST_VARIADIC_MACRO_MAYBE_STRIP_PARENS_2_I(...) __VA_ARGS__ 49 50namespace boost_no_cxx11_variadic_macros { 51 52void quiet_warning(int){} 53 54template<TEST_VARIADIC_MACRO_STRIP_PARENS((typename T,int))> struct test_variadic_macro_class {}; 55 56int test() 57{ 58 59 int x = TEST_VARIADIC_MACRO_STRIP_PARENS(3); 60 quiet_warning(x); 61 return 0; 62} 63 64} 65