Date: Fri, 18 Jun 2021 06:18:27 -0300
With C++ ranges today you can do :
auto const ints = {0,1,2,3,4,5,6};
auto d = ints | views::transform([](int x) { return x*2; });
https://godbolt.org/z/qszGT8xj6
You're right, I did read very quickly on this but it's the standard OR
> operator being used differently:
>
Well, I think that is a "good thing" if the language allows you to reuse
the syntax (operator overload) through library implementations without
changing the compiler.
> So there would seem be be a need here since this is not yet implemented if
> I am right.
>
Not yet, but being flexible to convert from ranges to *ANY* kind of
container may be challenging...
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1206r1.pdf
https://timur.audio/how-to-make-a-container-from-a-c20-range
We are also trying to avoid macros... they are not module-friendly, not
bounded to the type system, among many other issues:
https://stackoverflow.com/questions/14041453/why-are-preprocessor-macros-evil-and-what-are-the-alternatives
BR
Cleiton
auto const ints = {0,1,2,3,4,5,6};
auto d = ints | views::transform([](int x) { return x*2; });
https://godbolt.org/z/qszGT8xj6
You're right, I did read very quickly on this but it's the standard OR
> operator being used differently:
>
Well, I think that is a "good thing" if the language allows you to reuse
the syntax (operator overload) through library implementations without
changing the compiler.
> So there would seem be be a need here since this is not yet implemented if
> I am right.
>
Not yet, but being flexible to convert from ranges to *ANY* kind of
container may be challenging...
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1206r1.pdf
https://timur.audio/how-to-make-a-container-from-a-c20-range
We are also trying to avoid macros... they are not module-friendly, not
bounded to the type system, among many other issues:
https://stackoverflow.com/questions/14041453/why-are-preprocessor-macros-evil-and-what-are-the-alternatives
BR
Cleiton
Received on 2021-06-18 04:18:58