Given a boost::fusion::vector type, I want to filter out all the non-ref members to get a new type. For example this would transform boost::fusion::vector into boost::fusion::vector. I'm guessing the boost::fusion::filter_if meta function might be able to do this, but there's no example of its use in the documentation. Any suggestions would be appreciated.
Asked
Active
Viewed 392 times
0
-
Actually, there is an example here under **Print only pointers**: http://www.boost.org/doc/libs/1_61_0/libs/fusion/doc/html/fusion/quick_start.html – Adi Shavit Aug 31 '16 at 12:41
1 Answers
0
Something like this:
#include <iostream>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/algorithm/transformation/filter_if.hpp>
#include <boost/fusion/include/at_c.hpp>
#include <boost/fusion/include/equal_to.hpp>
#include <boost/fusion/include/make_vector.hpp>
#include <boost/mpl/assert.hpp>
using namespace boost::fusion;
int main(void)
{
int a = 10;
double b = 11.;
vector<int, int&, double, double&> vec(1, a, 13., b);
if(filter_if<boost::mpl::not_<boost::is_reference<boost::mpl::_>>>(vec) == make_vector(1, 13.))
std::cout << "MATCH" << std::endl;
}

Nim
- 33,299
- 2
- 62
- 101