Use:
A Boost_pp_seq_for_each macro that expands the parameters of a sequence by the specified macro in turn.
Grammar:
Boost_pp_seq_for_each (macro, data, SEQ)
variables:
Macro
A ternary macro defined in the Format macro(R, data, elem). The macro is boost_pp_seq_for_each as each element in the SEQ is expanded. To expand the macro, you need to use the next boost_pp_for Duplicate, alternate data, and current element.
Data
Backup data, used to pass to macro
Seq
Used to expand the macro by which sequence
Usage:
Boost_pp_seq_for_each is a duplicate of a macro.
If the sequence is (a) (b) (c), expand to:
Macro(R, Data, a) Macro(R, Data, b) Macro(R, Data, C)
If higher efficiency is required, use boost_pp_seq_for_each_r
Header file:
<boost/preprocessor/seq/for_each.hpp>
Example code:
1. Example 1
#include <boost/preprocessor/cat.hpp> #include <boost/preprocessor/seq/for_each.hpp> #define SEQ (w) (x) ( y) (z) #define MACRO (R, data, Elem) Boost_pp_cat (elem, data) Boost_pp_seq_for_each (macro, _, SEQ)//expands to W_ x_ y_ z_
2. Example 2
#include <boost/preprocessor/cat.hpp> #include <boost/preprocessor/seq/for_each.hpp> #define SEQ (w) (x) ( y) (z) #define MACRO (R, data, Elem) elem::getinstance () Boost_pp_seq_for_each (macro, _, SEQ)//Expands to W::getinstance () X::getinstance () y::getinstance () z::getinstance ()
The Boost_pp_seq_for_each of Boost learning