Boost logo

Boost Users :

From: noman javed (noman_bwp_at_[hidden])
Date: 2008-07-28 11:22:53


I want to apply some arbitrary function F on each element of a sequence through myfun class inherited from transform_view. I am unable to output the elements of the resultant sequence. Below is the whole code of my program

#include <boost/mpl/int.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/list_c.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/transform_view.hpp>
#include <iostream>

using namespace boost::mpl;    
namespace mpl = boost::mpl;

struct mysquare
{
    template< typename U > void operator()(U x)
    {
        static const int value = x*x;
    }
};

struct value_printer
{
    template< typename U > void operator()(U x)
    {
        std::cout << x << "   ";
    }
};

template<class F, class Seq>
struct myfun:transform_view<Seq,F>
{};

int main()
{
    
    using namespace std;
    typedef list_c<int,0,1,2,3,4,5> numbers;
    typedef myfun<mysquare,numbers>::type newnum;
    for_each<numbers>(value_printer());
//    for_each<newnum>(value_printer());  
 // I don,t know what transform_view return
}



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