ericniebler / range-v3

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

operator = for ranges::views::concat result #1817

Closed Jimmy-Hu closed 2 months ago

Jimmy-Hu commented 2 months ago

Considering the following code snippet

std::vector<int> a = {1, 2, 3};
std::deque<int> b = {4, 5, 6};
auto concat_result = ranges::views::concat(a);
concat_result = ranges::views::concat(b);  //  Error: error: no viable overloaded '='
// We can expect that concat_result is changed to {4, 5, 6} without error

The result of ranges::views::concat should be able to be overwritten without error in the last line.

brevzin commented 2 months ago

The result of ranges::views::concat should be able to be overwritten without error in the last line.

No, it shouldn't be. Those operations yield different types. If you want to type-erase the results so that you get the same type, that's up to you to do manually.