]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | [/ Copyright (C) 2009-2012 Lorenzo Caminiti ] | |
3 | [/ Distributed under the Boost Software License, Version 1.0 ] | |
4 | [/ (see accompanying file LICENSE_1_0.txt or a copy at ] | |
5 | [/ http://www.boost.org/LICENSE_1_0.txt) ] | |
6 | [/ Home at http://www.boost.org/libs/local_function ] | |
7 | ||
8 | [section:no_variadic_macros Annex: No Variadic Macros] | |
9 | ||
10 | This section illustrates an alternative syntax for compilers without variadic macro support. | |
11 | ||
12 | [heading Sequence Syntax] | |
13 | ||
14 | Most modern compilers support [@http://en.wikipedia.org/wiki/Variadic_macro variaid macros] (notably, these include GCC, MSVC, and all __CXX11__ compilers). | |
15 | However, in the rare case that programmers need to use this library on a compiler without variadic macros, this library also allows to specify its macro parameters using a __Boost_Preprocessor__ sequence where tokens are separated by round parenthesis `()`: | |
16 | ||
17 | (token1) (token2) ... // All compilers. | |
18 | ||
19 | Instead of the comma-separated list that we have seen so far which requires variadic macros: | |
20 | ||
21 | token1, token2, ... // Only compilers with varidic macros. | |
22 | ||
23 | For example, the following syntax is accepted on all compilers with and without variadic macros (see also [@../../test/add_seq.cpp =add_seq.cpp=]): | |
24 | ||
25 | [add_seq] | |
26 | ||
27 | However, on compilers with variadic macros the comma-separated syntax we have seen so far is preferred because more readable (see also [@../../test/add.cpp =add.cpp=]): | |
28 | ||
29 | [add] | |
30 | ||
31 | Note that the same macros accept both syntaxes on compilers with variadic macros and only the sequence syntax on compilers without variadic macros. | |
32 | Finally, an empty local function parameter list is always specified using `void` on compilers with and without variadic macros: | |
33 | ||
34 | [ten_void] | |
35 | ||
36 | [heading Examples] | |
37 | ||
38 | For reference, the following is a list of most of the examples presented in this documentation reprogrammed using the sequence syntax instead of the comma-separated syntax (in alphabetic order): | |
39 | ||
40 | [table | |
41 | [ [Files] ] | |
42 | [ [[@../../test/add_classifiers_seq.cpp =add_classifiers_seq.cpp=]] ] | |
43 | [ [[@../../test/add_default_seq.cpp =add_default_seq.cpp=]] ] | |
44 | [ [[@../../test/add_except_seq.cpp =add_except_seq.cpp=]] ] | |
45 | [ [[@../../test/add_inline_seq.cpp =add_inline_seq.cpp=]] ] | |
46 | [ [[@../../test/add_params_only_seq.cpp =add_params_only_seq.cpp=]] ] | |
47 | [ [[@../../test/add_template_seq.cpp =add_template_seq.cpp=]] ] | |
48 | [ [[@../../test/add_this_seq.cpp =add_this_seq.cpp=]] ] | |
49 | [ [[@../../test/add_typed_seq.cpp =add_typed_seq.cpp=]] ] | |
50 | [ [[@../../test/add_with_default_seq.cpp =add_with_default_seq.cpp=]] ] | |
51 | [ [[@../../test/all_decl_seq.cpp =all_decl_seq.cpp=]] ] | |
52 | [ [[@../../test/factorial_seq.cpp =factorial_seq.cpp=]] ] | |
53 | [ [[@../../test/macro_commas_seq.cpp =macro_commas_seq.cpp=]] ] | |
54 | [ [[@../../test/nesting_seq.cpp =nesting_seq.cpp=]] ] | |
55 | [ [[@../../test/overload_seq.cpp =overload_seq.cpp=]] ] | |
56 | [ [[@../../test/return_assign_seq.cpp =return_assign_seq.cpp=]] ] | |
57 | [ [[@../../test/return_derivative_seq.cpp =return_derivative_seq.cpp=]] ] | |
58 | [ [[@../../test/return_inc_seq.cpp =return_inc_seq.cpp=]] ] | |
59 | [ [[@../../test/return_setget_seq.cpp =return_setget_seq.cpp=]] ] | |
60 | [ [[@../../test/return_this_seq.cpp =return_this_seq.cpp=]] ] | |
61 | [ [[@../../test/same_line_seq.cpp =same_line_seq.cpp=]] ] | |
62 | [ [[@../../test/transform_seq.cpp =transform_seq.cpp=]] ] | |
63 | [ [[@../../test/typeof_seq.cpp =typeof_seq.cpp=]] ] | |
64 | [ [[@../../test/typeof_template_seq.cpp =typeof_template_seq.cpp=]] ] | |
65 | ] | |
66 | ||
67 | [endsect] | |
68 |