transform_iterator requirement on the Iterator?

Hi,
From the docs, I don't see the Iterator argument is required to be default-constructible.
I have a gcc4.3.3 error stack that looks like: /usr/include/boost-1_37/boost/iterator/iterator_adaptor.hpp: In constructor 'boost::iterator_adaptor<Derived, Base, Value, Traversal, Reference, Difference>::iterator_adaptor() [with Derived = boost::transform_iterator<Math::Curve1D<MathTest::Curve1D::CurveSVOTrait>::G etXIter, Math::CurveContainerIter<std::pair<double, double>, 4u, true>, boost::use_default, boost::use_default>, Base = Math::CurveContainerIter<std::pair<double, double>, 4u, true>, Value = const double, Traversal = boost::use_default, Reference = const double&, Difference = boost::use_default]': /usr/include/boost-1_37/boost/iterator/transform_iterator.hpp:100: instantiated from 'boost::transform_iterator<UnaryFunction, Iterator, Reference, Value>::transform_iterator() [with UnaryFunc = Math::Curve1D<MathTest::Curve1D::CurveSVOTrait>::GetXIter, Iterator = Math::CurveContainerIter<std::pair<double, double>, 4u, true>, Reference = boost::use_default, Value = boost::use_default]' /usr/lib/gcc/x86_64-redhat-linux/4.3.3/../../../../include/c++/4.3.3/bits/st l_algo.h:2086: instantiated from '_FIter std::lower_bound(_FIter, _FIter, const _Tp&) [with _FIter = boost::transform_iterator<Math::Curve1D<MathTest::Curve1D::CurveSVOTrait>::G etXIter, Math::CurveContainerIter<std::pair<double, double>, 4u, true>, boost::use_default, boost::use_default>, _Tp = double]' _____ math/interExtrapolators/interExtrapolate.hpp:75: instantiated from 'typename std::iterator_traits<fIterType>::value_type Math::InterExtrapolators::InterExtrapolate(xIterType, xIterType, fIterType, typename std::iterator_traits<_OI>::value_type, typename boost::call_traits<T>::param_type, typename boost::call_traits<Extrap>::param_type) [with Interp = Math::InterExtrapolators::StairCase1D, Extrap = Math::InterExtrapolators::StairCase1D, xIterType = boost::transform_iterator<Math::Curve1D<MathTest::Curve1D::CurveSVOTrait>::G etXIter, Math::CurveContainerIter<std::pair<double, double>, 4u, true>, boost::use_default, boost::use_default>, fIterType = boost::transform_iterator<Math::Curve1D<MathTest::Curve1D::CurveSVOTrait>::G etFIter, Math::CurveContainerIter<std::pair<double, double>, 4u, true>, boost::use_default, boost::use_default>]' ... mathTest/curve1D.cpp:72: instantiated from here /usr/include/boost-1_37/boost/iterator/iterator_adaptor.hpp:279: error: no matching function for call to 'Math::CurveContainerIter<std::pair<double, double>, 4u, true>::CurveContainerIter()' where it seems the compiler is looking for CurveContainerIter() with no arguments. but such constructor does not exist because the iterator has a member reference to the container. Or is this a requirement of std::lower_bound? Basically, the last line of the stack that is my code is xIterType xiter = std::lower_bound( xbegin, xend, x ); where xIterType is typedef boost::transform_iterator<GetXIter,ContainerConstIterType> xIterType; GetXIter is a unary function object, and ContainerConstIterType is CurveContainerIter<..., true> , true being for const'ness of the iterator. Xbegin, xend and x all of xIterType Regards,

2009/9/10 Hicham Mouline <hicham@mouline.org>:
From the docs, I don't see the Iterator argument is required to be default-constructible.
By Table 74 in the standard, all forward iterators are required to be default-constructible. I doubt you want your container iterators to be input iterators, and regardless, lower_bound requires forward iterators.

-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Scott McMurray Sent: 10 September 2009 15:23 To: boost-users@lists.boost.org Subject: Re: [Boost-users] transform_iterator requirement on the Iterator?
2009/9/10 Hicham Mouline <hicham@mouline.org>:
From the docs, I don't see the Iterator argument is required to be default-constructible.
By Table 74 in the standard, all forward iterators are required to be default-constructible.
I doubt you want your container iterators to be input iterators, and regardless, lower_bound requires forward iterators. _______________________________________________
My iterators are constructed to make them point inside a given container, for that they store a reference to the container. Therefore I cannot provide a default constructor, or can I? Do I need to change the implementation of the iterator to allow default construction so that I can use lower_bound with it?

2009/9/10 Hicham Mouline <hicham@mouline.org>:
My iterators are constructed to make them point inside a given container, for that they store a reference to the container. Therefore I cannot provide a default constructor, or can I?
Do I need to change the implementation of the iterator to allow default construction so that I can use lower_bound with it?
The default constructor is expected to give a mostly-useless singular iterator. Changing the reference to a pointer should solve everything.
participants (2)
-
Hicham Mouline
-
Scott McMurray