The macro is in the directory.
Boost/Preprocessor/Iteration/local. HPP
The document says that its role is:
This macro customizes the macroBoost_pp_local_macro
ToBoost_pp_local_limits
The values in the specified range are vertically expanded.
An example is provided:
# Include <boost/Preprocessor/Iteration/local. HPP> <br/> template <int> struct sample; <br/> # define boost_pp_local_macro (N) /<br/> template <> struct sample <n >{/ <br/> Enum {value = n };/}; /<br/>/**/<br/> # define boost_pp_local_limits (1, 5) <br/> # include boost_pp_local_iterate ()
It is expanded:
Template <> struct sample <1 >{ Enum {value = 1}; <br/> template <> struct sample <2 >{ Enum {value = 2 }; <br/> template <> struct sample <3> {Enum {value = 3}; <br/> template <> struct sample <4> {Enum {value = 4 }; <br/> template <> struct sample <5> {Enum {value = 5 };
The above Code cannot be compiled in vc2008, but it only needs to be modified. The above code is changed:
# Include <boost/Preprocessor/Iteration/local. HPP> <br/> template <int n> struct sample; <br/> # define boost_pp_local_macro (N) template <> struct sample <n >{enum {value = n };}; // you need to create a row. <Br/> # define boost_pp_local_limits (1, 5) <br/> # include boost_pp_local_iterate ()
Boost_pp_local_macro macro and boost_pp_local_limits macro are both user-defined codes.
Boost_pp_local_limits must be followed by a space (at least ). Like the above
# Define boost_pp_local_limits (1, 5 ). This means that () is not a macro parameter or a whole.
Boost_pp_local_limits itself represents)
The boost_pp_local_iterate macro code is defined as follows:
# Define boost_pp_local_iterate () <boost/Preprocessor/Iteration/detail/local. HPP> <br/> // This clearly indicates that a header file is included. to use it, you must # include boost_pp_local_iterate () <br/> // expand: <br/> // # include <boost/Preprocessor/Iteration/detail/local. HPP>
The local. HPP code is as follows:
# If! Defined (boost_pp_local_limits) // user-defined range, such as: (3, 9) <br/> # error boost_pp_error: local iteration boundaries are not defined // no definition error <br/> # Elif! Defined (boost_pp_local_macro) // User-Defined generated code, as shown in the preceding example <br/> # error boost_pp_error: local iteration target macro is not defined // if not defined, an error is returned. <br/> # else <br/> # If ~ Boost_pp_config_flags () & boost_pp_config_edg () <br/> // boost_pp_tuple_elem (size, I, tuple) the first macro parameter is the size of tuple <br/> // If tuple is (2, 3), size = 2, I is the index, starting from 0. If I = 0, 2 is returned. <br/> // If I = 1, 3 is returned. <br/> # define boost_pp_local_s boost_pp_tuple_elem (2, 0, boost_pp_local_limits) <br/> # define boost_pp_local_f limit (2, 1, boost_pp_local_limits) <br/> # else <br/> # define boost_pp_value limit (2, 0, boost_pp_local_limits) <br/> # include <boost/Preprocessor/Iteration/detail/start. HPP> <br/> # define boost_pp_value boost_pp_tuple_elem (2, 1, boost_pp_local_limits) <br/> # include <boost/Preprocessor/Iteration/detail/finish. HPP> <br/> # define boost_pp_local_s boost_pp_local_se () <br/> # define boost_pp_local_f boost_pp_local_fe () <br/> # endif <br/> # If (boost_pp_local_s)> (boost_pp_local_f) // if the first element is smaller than the second <br/> # include <boost/Preprocessor/Iteration/detail/rlocal. HPP> <br/> # else // otherwise <br/> # If boost_pp_local_c (0) // # define boost_pp_local_c (N) (boost_pp_local_s) <= N & (boost_pp_local_f)> = N, which indicates whether the boost_local_macro (0) // code written by the user. <Br/> # endif <br/> # If boost_pp_local_c (1) <br/> boost_pp_local_macro (1) <br/> # endif <br/> # If boost_pp_local_c (2) <br/> boost_pp_local_macro (2) <br/> # endif <br/> # If boost_pp_local_c (3) <br/> boost_pp_local_macro (3) <br/> # endif <br/> # If boost_pp_local_c (4) <br/> boost_pp_local_macro (4) <br/> # endif <br/> # If boost_pp_local_c (5) <br/> boost_pp_local_macro (5) <br/> # endif <br/> # If boost_pp_local_c (6) <br/> boost_pp_local_macro (6) <br/> # endif <br/> # If boost_pp_local_c (7) <br/> boost_pp_local_macro (7) <br/> # endif <br/> # If boost_pp_local_c (8) <br/> boost_pp_local_macro (8) <br/> # endif <br/> # If boost_pp_local_c (9) <br/> boost_pp_local_macro (9) <br/> # endif <br/> # If boost_pp_local_c (10) <br/> boost_pp_local_macro (10) <br/> # endif <br/> # If boost_pp_local_c (11) <br/> boost_pp_local_macro (11) <br/> # endif <br/> # If boost_pp_local_c (12) <br/> boost_pp_local_macro (12) <br/> # endif <br/> # If boost_pp_local_c (13) <br/> boost_pp_local_macro (13) <br/> # endif <br/> # If boost_pp_local_c (14) <br/> boost_pp_local_macro (14) <br/> # endif <br/> # If boost_pp_local_c (15) <br/> boost_pp_local_macro (15) <br/> # endif <br/> # If boost_pp_local_c (16) <br/> boost_pp_local_macro (16) <br/> # endif <br/> # If boost_pp_local_c (17) <br/> boost_pp_local_macro (17) <br/> # endif <br/> # If boost_pp_local_c (18) <br/> boost_pp_local_macro (18) <br/> # endif <br/> # If boost_pp_local_c (19) <br/> boost_pp_local_macro (19) <br/> # endif <br/> # If boost_pp_local_c (20) <br/> boost_pp_local_macro (20) <br/> # endif <br/> # If boost_pp_local_c (21) <br/> boost_pp_local_macro (21) <br/> # endif <br/> # If boost_pp_local_c (22) <br/> boost_pp_local_macro (22) <br/> # endif <br/> # If boost_pp_local_c (23) <br/> boost_pp_local_macro (23) <br/> # endif <br/> # If boost_pp_local_c (24) <br/> boost_pp_local_macro (24) <br/> # endif <br/> # If boost_pp_local_c (25) <br/> boost_pp_local_macro (25) <br/> # endif <br/> # If boost_pp_local_c (26) <br/> boost_pp_local_macro (26) <br/> # endif <br/> # If boost_pp_local_c (27) <br/> boost_pp_local_macro (27) <br/> # endif <br/> ....... content omitted <br/> ....... <br/> # If boost_pp_local_c (252) <br/> boost_pp_local_macro (252) <br/> # endif <br/> # If boost_pp_local_c (253) <br/> boost_pp_local_macro (253) <br/> # endif <br/> # If boost_pp_local_c (254) <br/> boost_pp_local_macro (254) <br/> # endif <br/> # If boost_pp_local_c (255) <br/> boost_pp_local_macro (255) <br/> # endif <br/> # If boost_pp_local_c (256) <br/> boost_pp_local_mac RO (256) // from 0 till 256 <br/> # endif <br/> # UNDEF boost_pp_local_limits <br/> # <br/> # UNDEF boost_pp_local_s <br/> # UNDEF boost_pp_local_f <br/> # UNDEF boost_pp_local_macro
The index range above can also be written backwards:
For example, write ())
The rest of the code is also written backwards:
# If boost_pp_local_r (256) <br/> boost_pp_local_macro (256) <br/> # endif <br/> # If boost_pp_local_r (255) <br/> boost_pp_local_macro (255) <br/> # endif <br/> # If boost_pp_local_r (254) <br/> boost_pp_local_macro (254) <br/> # endif <br/> # If boost_pp_local_r (253) <br/> boost_pp_local_macro (253) <br/> # endif <br/> ............. <br/> .............
Boost_pp_local_r code:
# Define boost_pp_local_r (N) (boost_pp_local_f) <= N & (boost_pp_local_s)> = N
This is the boost_pp_local_iterate () Macro function.