Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Range and initializer_list
From: Michel Morin (mimomorin_at_[hidden])
Date: 2018-04-17 11:17:54


Robert Jones via Boost-users wrote:
> for( int i : { 1, 2, 3 } | reversed ) { cout << i << " "; } // Bad

Boost.Range is not relevant here (other than the prvalue problem).
`{...} | ...` is not allowed in C++.
See https://bugs.llvm.org/show_bug.cgi?id=13069

In C++2a, you can use this

    for (auto rng = {...}; auto&& x : rng | ...) {...}

thanks to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0614r1.html.

Regards,
Michel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net