Boost logo

Boost Users :

Subject: [Boost-users] [fusion] more trouble with transform
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2011-11-12 06:03:20


Hi,

Now I am trying to perform transform which mutates:

------
#include <boost/fusion/container/list/list.hpp>
#include <boost/fusion/container/list/convert.hpp>
#include <boost/fusion/container/generation/make_list.hpp>
#include <boost/fusion/algorithm/transformation/transform.hpp>
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<make_c(T&)>
    {
        typedef C type;
    };
    template <typename T>
    struct result<make_c(T)>
    {
        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

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net