← Back to context

Comment by einpoklum

3 days ago

But the standard library should have had things so that we can write:

    constexpr std::array types = {^^int, ^^float, ^^double};
    auto sizes = std::whatever::transform(types, std::meta::size_of);

which would have been even nicer.

It would have been, but it looks like the difficulty there is that the type of `sizes` must be compile time known, but `std::transform` and friends don't really know about fixed sizes. Depending on the context, one can do `auto sizes = types | std::views::transform(std::meta::size_of);`, the difficulty comes in materializing at the end.