[fusion] for_each

I think it's at least partly my mistake. It took me some time to manage a limited example not compiling: #include <boost/fusion/container/set.hpp> #include <boost/fusion/container/vector.hpp> #include <boost/fusion/include/at_key.hpp> #include <boost/fusion/include/for_each.hpp> #include <boost/fusion/include/as_vector.hpp> struct A { int adata; }; struct B { int bdata; }; struct C { int cdata; }; typedef boost::fusion::set<A, B, C> my_set_type; typedef boost::fusion::vector<A, B> my_vector_type; struct update { update(my_set_type& to_overwrite_):to_overwrite(to_overwrite_){} template<typename T> void operator()(T& elt) const { boost::fusion::at_key<T>(to_overwrite)=elt; } my_set_type& to_overwrite; }; int main() { my_set_type my_set; my_vector_type my_vec; boost::fusion::for_each(boost::fusion::as_vector(my_vec),update(my_set)); } Now it will compile if you replace boost::fusion::as_vector(my_vec) by my_vec or T& by T const&. Ok so it seems my problem description is wrong and I needed to know that as_vector returns a const vector, right? Thanks, Christophe
participants (1)
-
Christophe Henry