Boost logo

Boost Users :

Subject: [Boost-users] Boost.Range and initializer_list
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2018-04-16 21:06:08


Hi All

Does the Boost.Range library support initializer_list as a range type? I
thought anything with begin() and end() methods was fair game, but this
code doesn't work, unless I'm doing it wrong.

#include <iostream>
#include <vector>
#include <boost/range/adaptor/reversed.hpp>

int main( )
{
  using namespace std;
  using namespace boost::adaptors;

  vector<int> v { 1, 2, 3 };
  for( int i : v | reversed ) { cout << i << " "; } // Ok
  for( int i : { 1, 2, 3 } | reversed ) { cout << i << " "; } // Bad
}

Kind Regards

Rob.



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