This recipe will show a tiny piece of the Boost.Fusion
library's abilities. We'll be splitting a single tuple into two tuples, one with arithmetic types and the other with all other types.
This recipe requires knowledge of Boost.MPL
, placeholders, and Boost.Tuple
. Reading this chapter from the beginning is recommended.
This is possibly one of the hardest recipes in this chapter. The resulting types are determined at compile time and values for those types are filled at runtime:
- To implement that mix, we need the following headers:
#include <boost/fusion/include/remove_if.hpp> #include <boost/type_traits/is_arithmetic.hpp>
- Now, we are ready to make a function that returns non-arithmetic types:
template <class Sequence> typename boost::fusion::result_of::remove_if< const Sequence, boost::is_arithmetic<boost::mpl::_1> >::type get_nonarithmetics(const Sequence& seq) { return boost::fusion::remove_if< ...