Boost logo

Boost :

Subject: [boost] Change in range requirements
From: Ganssauge, Gottfried (Gottfried.Ganssauge_at_[hidden])
Date: 2015-01-30 13:26:57


Please consider the following program:

bool predicate(char c) {
    return c != '0';
}

int main (int, char **) {
    using namespace boost::adaptors;

    boost::copy(
        boost::make_iterator_range(
            std::istream_iterator<char>(std::cin >> std::noskipws),
            std::istream_iterator<char>()) | filtered(predicate),
        std::ostream_iterator<char>(std::cout));
    return 0;
}

It works brilliantly with boost-1.54 although std::istream_iterator is only an input iterator.
Recently I tried switching to boost-1.57, but suddenly this program stopped working - it won't compile any longer, because istream_iterator is not a forward_iterator:

g++ -I ~/source/aurora-python/test-build/parts/boost range_filter.cpp -o range_filter
... # lots of gobbledygook skipped
range_filter.cpp:18:64: required from here
/home/gotti/source/aurora-python/test-build/parts/boost/boost/concept_check.hpp:210:13: error: conversion from 'boost::iterators::single_pass_traversal_tag' to non-scalar type 'boost::iterators::forward_traversal_tag' requested
       Y y = x;
             ^

When I build an equivalent program using boost::filter_iterator it keeps compiling and working fine.

Why is it, that the requirements for certain range adaptors (e.g. filtered, transformed) suddenly exclude input ranges?
The corresponding iterator adaptors keep working...

Gottfried Ganßauge
Entwickler
Content Engineering & Development

------------------------------------------------------------------
Haufe-Lexware GmbH & Co. KG
Ein Unternehmen der Haufe Gruppe
Munzinger Str. 9, 79111 Freiburg
Tel. +49 761 898-0
Internet: http://www.haufe-lexware.com
------------------------------------------------------------------
Kommanditgesellschaft, Sitz und Registergericht Freiburg, HRA 4408
Komplementäre: Haufe-Lexware Verwaltungs GmbH, Sitz und Registergericht Freiburg, HRB 5557; Martin Laqua
Beiratsvorsitzende: Andrea Haufe
Geschäftsführung: Isabel Blank, Markus Dränert, Jörg Frey, Birte Hackenjos, Randolf Jessl, Markus Reithwiesner, Joachim Rotzinger, Dr. Carsten Thies
------------------------------------------------------------------


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk