
Gennadiy Rozental
Hi,
Now I am trying to perform transform which mutates:
------ #include
#include #include #include namespace fusion=boost::fusion; struct C {};
struct B { C make_c() { return C(); } };
struct make_c { template<typename Sig> struct result;
template <typename T> struct result
{ typedef C type; }; template <typename T> struct result { typedef C type; }; template <typename T> C operator()(T& t) const { return t.make_c(); } };
int main() { B b1, b2; auto z1 = fusion::make_list( b1, b2 );
auto z2 = fusion::as_list( fusion::transform( z1, make_c() ) );
return 0; } ----
Both gcc and msvc complain like this:
test.cpp:29:46: error: passing ‘const B’ as ‘this’ argument of ‘C B::make_c()’ discards qualifiers.
What am I missing now?
Gennadiy
fusion::transform only accepts cref-qualified sequences. That is why the resulting transform view will be store a reference to z1 const and thus the arguments passed to make_c are const-qualified. https://svn.boost.org/trac/boost/ticket/3446 Construct the transform view by hand and your example should work fine. Christopher