-
Anonymous
Почему нельзя присвоить представлению тот же тип представления?
Сообщение
Anonymous »
Почему я не могу (пере)назначить значение для представления того же типа?
Демо:
https://godbolt.org/z/aqdh7ohva< /p>
Код: Выделить всё
#include
#include
#include
int main()
{
std::vector v = { 0, 1, 2, 3, 4, 5, 6 };
const bool strategy_check_for_zero = true;
auto selected = v | std::views::filter([=](const auto& v) { return !strategy_check_for_zero || v != 0; });
// Impossible to do; why?
selected = v | std::views::filter([=](const auto& v) { return true; });
std::ranges::copy(selected, std::ostream_iterator{std::cout, ", "});
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79365549/why-cant-a-view-be-assigned-with-the-same-type-of-the-view[/url]
1737144169
Anonymous
Почему я не могу (пере)назначить значение для представления того же типа?
Демо: https://godbolt.org/z/aqdh7ohva< /p>
[code]#include
#include
#include
int main()
{
std::vector v = { 0, 1, 2, 3, 4, 5, 6 };
const bool strategy_check_for_zero = true;
auto selected = v | std::views::filter([=](const auto& v) { return !strategy_check_for_zero || v != 0; });
// Impossible to do; why?
selected = v | std::views::filter([=](const auto& v) { return true; });
std::ranges::copy(selected, std::ostream_iterator{std::cout, ", "});
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79365549/why-cant-a-view-be-assigned-with-the-same-type-of-the-view[/url]