Hi All, I'm trying to do some slightly hooky stuff with the iterators library and cannot get the following code to compile. When the second last line of main is uncommented ("ZIter iter(b);"), compilation fails. The error mesages suggest this is a problem with determining the appropriate traversal category of "ZIter". Can anyone advise if this is problem with my code, a bug, am I asking too much of the library, ...? Cheers, Simon Knapp. compiler: Visual Studio 2008 - version 9.0.30729.1 SP //---------------------------------------------------------------------------------------------------------------------------- // begin iterator_tests.cpp //---------------------------------------------------------------------------------------------------------------------------- #include <vector> #include <boost/iterator/filter_iterator.hpp> #include <boost/iterator/zip_iterator.hpp> #include <boost/tuple/tuple.hpp> typedef std::vector<long long> LLGrid; typedef std::vector<float> FloatGrid; typedef LLGrid::const_iterator LLGridIter; typedef FloatGrid::const_iterator FloatGridIter; typedef boost::tuples::tuple<LLGridIter, FloatGridIter> IDAndAreaTuple; typedef boost::zip_iterator<IDAndAreaTuple> IDAndAreaIterator; typedef std::iterator_traits<IDAndAreaIterator>::reference IDAndAreaRef; struct Fnctr { bool operator()(const IDAndAreaRef ref) const { return true; } }; typedef boost::filter_iterator<Fnctr, IDAndAreaIterator> FIter; typedef boost::tuples::tuple<FloatGridIter, FIter> ZIterTuple; typedef boost::zip_iterator<ZIterTuple> ZIter; static ZIterTuple makeZIterTuple( Fnctr const& fnctr, LLGridIter const& beginIdGrid, LLGridIter const& endIdGrid, FloatGridIter const& beginAreaGrid, FloatGridIter const& endAreaGrid, FloatGridIter const& gtgdIter ) { return boost::make_tuple( gtgdIter, boost::make_filter_iterator( fnctr, boost::make_zip_iterator(boost::make_tuple(beginIdGrid, beginAreaGrid)), boost::make_zip_iterator(boost::make_tuple(endIdGrid, endAreaGrid)) ) ); } int main(int argc, char* argv[]) { FloatGrid areaMask, regionStat; LLGrid regionMask; ZIterTuple b(makeZIterTuple(Fnctr(), regionMask.begin(), regionMask.end(), areaMask.begin(), areaMask.end(), regionStat.begin())); //ZIter iter(b); return 0; } //---------------------------------------------------------------------------------------------------------------------------- // end iterator_tests.cpp //----------------------------------------------------------------------------------------------------------------------------
2013/1/10 Simon Knapp:
Hi All,
I'm trying to do some slightly hooky stuff with the iterators library and cannot get the following code to compile.
When the second last line of main is uncommented ("ZIter iter(b);"), compilation fails.
The error mesages suggest this is a problem with determining the appropriate traversal category of "ZIter".
Can anyone advise if this is problem with my code, a bug, am I asking too much of the library, ...?
What boost version are used? With gcc-4.7.2 & boost-1.49/boost-1.50 - no problems: http://liveworkspace.org/code/33S7Mc$0 -- Regards, niXman ___________________________________________________ Dual-target(32 & 64-bit) MinGW compilers for 32 and 64-bit Windows: http://sourceforge.net/projects/mingwbuilds/ ___________________________________________________ Another online IDE: http://liveworkspace.org/
participants (2)
-
niXman
-
Simon Knapp