joboccara/pipes

Using ptr to member as pipes field ?

Milerius opened this issue · 1 comments

Let's say i have the following code:

struct vertex
    {
        transform::position_2d pos{transform::position_2d::scalar(0.f)};
        transform::position_2d texture_pos{transform::position_2d::scalar(0.f)};
        graphics::color pixel_color{graphics::white};
    };

    struct vertex_array
    {
        std::vector<vertex> vertices;
        vertex_geometry_type geometry_type;
    };

// logic code
 for (auto &v : array_cmp.vertices) v.pixel_color = clr_winner;

What i would like to achieve with pipes is smth like:

struct vertex
    {
        transform::position_2d pos{transform::position_2d::scalar(0.f)};
        transform::position_2d texture_pos{transform::position_2d::scalar(0.f)};
        graphics::color pixel_color{graphics::white};
    };

    struct vertex_array
    {
        std::vector<vertex> vertices;
        vertex_geometry_type geometry_type;
    };

//logic code
array_cmp.vertices >>= pipes::member(&geometry::vertex::pixel_color) >>= pipes::fill(clr_winner) >>= pipes::override(array_cmp.vertices);

// or
array_cmp.vertices >>=  pipes::fill(&geometry::vertex::pixel_color, clr_winner) >>= pipes::override(array_cmp.vertices);

Do you think it's will be possible to achieve ?

The equivalent in range is: ranges::fill(views::transform(array_cmp.vertices, &geometry::vertex::pixel_color), clr_winner);

i hope range v3 will allow us to do: ranges::fill(array_cmp.vertices, &geometry::vertex::pixel_color, clr_winner)

Little remark about the pipe library: is great but for me the big problem is unfortunately ADL:

We cannot write: std::cout << endl; so we cannot write pipes::functionality() >>= another_functionality() which will be so much cleaner to read/write.