Boost logo

Boost Users :

Subject: [Boost-users] [spirit][karma][range] Range adaptors not handled by karma?
From: Ravi (lists_ravi_at_[hidden])
Date: 2011-03-20 04:50:36


Hi,
  Does spirit karma handle boost.range adaptors correctly? The following code
compiles but fails at run-time as the end of the range is not seen by karma:

--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
#include <boost/range/adaptors.hpp>
#include <boost/assign.hpp>
#include <iostream>
#include <vector>

#include <boost/spirit/include/karma.hpp>

int main(int argc, const char* argv[])
{
  using namespace boost::adaptors;
  using namespace boost::assign;

  std::vector<int> input;
  input += 1,2,3,4,5,6,7,8,9,10;

  std::ostream_iterator<char> os( std::cout );

  using boost::spirit::karma::int_;
  using boost::spirit::karma::generate_delimited;
  using boost::spirit::ascii::space;
  //generate_delimited( os, int_ % ',', space,
  // input | strided(2) ); // <- works
  generate_delimited( os, int_ % ',', space,
                      input | copied(1,6) | strided(2) );

  std::cout << std::endl;
  return 0;
}
--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--

The tests were done with boost 1.45.

Regards,
Ravi


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