Boost logo

Boost :

From: fresl_at_[hidden]
Date: 2001-03-17 13:53:51


It seems impossible to compile
`transform_iterator_example.cpp'
either with g++ (one of the latest snapshots from
`http://www.codesourcery.com/gcc-snapshots.html',
with its own library) or Comeau's compiler `como'
(with its library) because:

"/home/krcko/include/boost/iterator_adaptors.hpp",
line 832: error: no default constructor exists for class
   "std::binder1st<std::plus<int>>"
         transform_iterator_policies() { }
                                    ^
    detected during:
    instantiation of
       "boost::transform_iterator_policies<
        AdaptableUnaryFunction>::transform_iterator_policies()
       [...]
    instantiation of
       "boost::details::compressed_pair_imp<
        T1, T2, 0>::compressed_pair_imp()
       [...]
    instantiation of
       "boost::compressed_pair<T1,T2>::compressed_pair()
       [...]
    instantiation of
       "boost::iterator_adaptor<Base, Policies, Value,
                      Reference, Pointer, Category,
                      Distance>::iterator_adaptor()
       [...]
     instantiation of
        "_Type_STL_ERROR::
         __default_constructor_requirement_violation(_Type)
        [...]
     instantiation of
        "void _DefaultConstructible_concept_specification<_Type>
         ::_DefaultConstructible_requirement_violation(_Type)
        [...]
     instantiation of
        "void _TrivialIterator_concept_specification<
         _TrivialIterator>::
         _TrivialIterator_requirement_violation(_TrivialIterator)
        [...]
     instantiation of
        "void _InputIterator_concept_specification<
         _InputIterator>::
         _InputIterator_requirement_violation(_InputIterator)
        [...]
     instantiation of
        "_OutputIter std::copy(_InputIter, _InputIter,
                               _OutputIter)
        [...]
     at line 38 of "transform_iterator_example.cpp"

   
When `std::bind1st(std::plus<int>(), 4)' is replaced
by `std::negate<int>()' in the call of `std::copy()',
example can be compiled by both compilers -- struct
`std::negate<>' (at least in g++ and como libraries)
has only `operator()' and therefore compilers can
generate default constructor.

It is possible to cheat and add default constructor to
`std::binder1st<>' (and to `binder2nd<>' and to ...),
but I wonder what standard says about default-construct-
ability of these functors.

Sincerely,

Kresimir Fresl


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