Hi!
please see my answer below.
On Sat, Nov 12, 2011 at 12:03 PM, Gennadiy Rozental wrote:
Hi,
Now I am trying to perform transform which mutates:
int
main()
{
B b1, b2;
auto z1 = fusion::make_list( b1, b2 ); !!! create a list of copied Bs
auto z2 = fusion::as_list( fusion::transform( z1, make_c() ) ); !!!
copies Bs again
return 0;
}
You need to make a list of references to Bs:
This is a slighly modified code which compiled in msvc
#include
#include
#include
#include
#include
using namespace boost;
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( ref(b1), ref(b2) );
auto z2 = fusion::as_list( fusion::transform( z1, make_c() ) );
return 0;
}
Regards,
Ovanes