C++ Logo

std-proposals

Advanced search

Re: [std-proposals] ranges::to valarray (from_range_t for valarray constructor)

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Sun, 7 Jan 2024 08:03:39 +0000
On Sun, 7 Jan 2024, 04:30 Liu Yihua via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> Hi all,
>
> Currently, we can write
> ```cpp
> std::valarray<double> va = {1, 2};
> auto new_vec = va | std::ranges::views::take(2) | std::
> ranges::to<std::vector<double>>();
> ```
> but not
> ```cpp
> auto new_va = va | std::ranges::views::take(2) | std::
> ranges::to<std::valarray<double>>();
> ```
>

You also can't write:
valarray<double> va{vec.begin(), vec.end()};

Is that actually useful though?

Do you have real world practical uses for valarrays of dynamic/arbitrary
size created this way?




>

Received on 2024-01-07 08:03:54