Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ptr to member as pipes field ? #29

Open
Milerius opened this issue Oct 14, 2019 · 1 comment
Open

Using ptr to member as pipes field ? #29

Milerius opened this issue Oct 14, 2019 · 1 comment

Comments

@Milerius
Copy link

Milerius commented Oct 14, 2019

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 ?

@Milerius
Copy link
Author

Milerius commented Oct 14, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant