You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to C++23 draft, there will be a ranges::to() to be implemented.
Constructing containers and strings from ranges with ranges::to(), tagged constructors, insert and assign member functions. P1206R7
I tested ranges::to() in develop version of clang because current gcc does not support. It works but I found that it has a rather poor performance.
vector<int> v auto vec = views::iota(-10, 10) | views::filter([](int i) {return i>0;}) | ranges::to<vector<int>>();
I think that the main reason is that a new container has to be created every time the view runs. Thus it is reasonable if we could supply a variant ranges::to() which accept a reusable container as a parameter. like ranges::to_container(T container).
There are at least two benefits based on the above thought:
The reusable container can avoid unnecessary reallocating ;
We can collect different views into a same container;
Since ranges::to() is somehow similar to collect() in rust lang, I found a couterpart of ranges::to_container(T container) there:
a.iter().collect_into(&mut vec);
The collect_into() is what I would like to propose.
The text was updated successfully, but these errors were encountered:
This repository is just for the text of the standard, not for proposed changes or additions to the standard. Please see https://isocpp.org/std/submit-a-proposal instead.
According to C++23 draft, there will be a ranges::to() to be implemented.
I tested ranges::to() in develop version of clang because current gcc does not support. It works but I found that it has a rather poor performance.
vector<int> v auto vec = views::iota(-10, 10) | views::filter([](int i) {return i>0;}) | ranges::to<vector<int>>();
I think that the main reason is that a new container has to be created every time the view runs. Thus it is reasonable if we could supply a variant ranges::to() which accept a reusable container as a parameter. like ranges::to_container(T container).
There are at least two benefits based on the above thought:
Since ranges::to() is somehow similar to collect() in rust lang, I found a couterpart of ranges::to_container(T container) there:
a.iter().collect_into(&mut vec);
The collect_into() is what I would like to propose.
The text was updated successfully, but these errors were encountered: