I would like to access the boost::tuple element with phoenix(c++98)
#include <boost/tuple/tuple.hpp>
#include <boost/phoenix.hpp>
#include <algorithm>
#include <vector>
int main()
{
using namespace boost::phoenix::placeholders;
std::vector<boost::tuple<int> > vec;
vec.push_back(boost::make_tuple(3));
vec.push_back(boost::make_tuple(4));
std::for_each(vec.begin(), vec.end(), std::cout<<boost::get<0>(arg1)<<std::endl);
}
But it cannot work, I have tried with std::pair and self define struct, but they cannot work either. Is it possible to access those element with some intuitive, easy solution?
Just find out you can use boost::phoenix::at_c to access tuple element
std::for_each(vec.begin(), vec.end(), std::cout<<boost::phoenix::at_c<0>(arg1)<<std::endl);
You can access std::pair with phoenix too, but need to include the header
#include <boost/fusion/adapted.hpp>
Still lack the example of access self define struct, if I can figure it out I would post it
Edit : you need to include
#include <boost/phoenix/fusion.hpp>
else at_c may not found