ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.12k stars 440 forks source link

No action for remove (without if)? #1015

Closed tower120 closed 5 years ago

tower120 commented 5 years ago

Is there a particular reason, why there is no action::remove / view::remove ?

ericniebler commented 5 years ago

No reason, short of a lack of time. Can I interest you in submitting a PR?

tower120 commented 5 years ago

Can I interest you in submitting a PR?

I'll make PR with action::remove/action::unstable_remove/view::remove, as soon as we dealt with unstable_remove_if. Leaving this issue opened, to link with future PR.

tower120 commented 5 years ago

I'm trying to implement action::remove as wrapper around action::remove_if .

I think, I bumped into the same thing as with views. Does actions must be Semiregular too?

Following wan't compile: https://wandbox.org/permlink/2cqBMYc1lTAoJ5w2

#include <iostream>
#include <vector>

#include <range/v3/action/remove_if.hpp>

struct Pred{    
    int i = 2;

    Pred(const Pred&) = delete;
    Pred(Pred&&) = default;
    Pred() = default;

    bool operator()(int other) const {
        return other == i;
    }
};

void test_value_capture(){
    using List = std::vector<int>;
    List list{};
    list |= ranges::action::remove_if(Pred());

    std::cout << list.empty();
}

int main()
{
    test_value_capture();
}