Permutation Iterator Adaptor Problem
I'm trying to use the Permutation Iterator adaptor on MSV++ w/SP5 with
boost_1_27_0. Below is a simplification of the example on the web site,
which results in the compiler error found below function main: Any ideas?
#include <list>
#include <vector>
#include
I just tried your code with gcc-2.95.3 as well as gcc-3.0.3 and no problems there. Looking at the status page, the iterator_adaptors test, which includes a test for the permutation_iterator, compiles fine with VC++ 6.0 SP5. I don't use windows though so that's all I can say at this point. I do want to add that, if your compilation succeeds, you will have a runtime error. The only index you have is '1' although the elements container is of size() 1 (and thus the only valid index is zero) Jeff Flinn - wwnet wrote:
I'm trying to use the Permutation Iterator adaptor on MSV++ w/SP5 with boost_1_27_0. Below is a simplification of the example on the web site, which results in the compiler error found below function main: Any ideas?
#include <list> #include <vector> #include
int main(int argc, char* argv[]) { typedef std::vector < int > tElements; typedef tElements::iterator tEItr; typedef std::list < int > tIdxs; typedef tIdxs::iterator tIItr; typedef std::ostream_iterator< int > tOItr;
tElements elements( 1, 1 ); tIdxs indices ( 1, 1 );
typedef boost::permutation_iterator_generator< tEItr, tIItr >::type tPItr;
tPItr begin = boost::make_permutation_iterator( elements.begin(), indices.begin() );
int val = *begin;
return 0; }
error C2440: 'initializing' : cannot convert from 'struct boost::detail::iterator_traits_::undefined<void>' to 'int' Source or target has incomplete type
I've discovered the difference between the
http://www.boost.org/libs/utility/permutation_iterator.htm example and the
http://www.boost.org/libs/utility/iterator_adaptor_test.cpp test code is
that the former (along with the example below) use vector<int> as the
element_range_type, while the latter uses deque<int>. In my environment,
permutation iterator works when used with deques but doesn't compile using
vector as exhibited below. I've copied the test case and replaced deque with
vector reproducing the problem.
Again the compiler complains about "struct
boost::detail::iterator_traits_::undefined<void>". Since Toon says that the
below code works with with gcc-2.95.3 as well as gcc-3.0.3, does any one
know of MSVC vector issues that could be the source of this problem? I will
try this using MSVC and STLPORT this evening on another machine to see if
the problem persists.
Thanks, Jeff
----- Original Message -----
From: "Toon Knapen"
I just tried your code with gcc-2.95.3 as well as gcc-3.0.3 and no problems there. Looking at the status page, the iterator_adaptors test, which includes a test for the permutation_iterator, compiles fine with VC++ 6.0 SP5. I don't use windows though so that's all I can say at this point.
I do want to add that, if your compilation succeeds, you will have a runtime error. The only index you have is '1' although the elements container is of size() 1 (and thus the only valid index is zero)
Jeff Flinn - wwnet wrote:
I'm trying to use the Permutation Iterator adaptor on MSV++ w/SP5 with boost_1_27_0. Below is a simplification of the example on the web site, which results in the compiler error found below function main: Any ideas?
#include <list> #include <vector> #include
int main(int argc, char* argv[]) { typedef std::vector < int > tElements; typedef tElements::iterator tEItr; typedef std::list < int > tIdxs; typedef tIdxs::iterator tIItr; typedef std::ostream_iterator< int > tOItr;
tElements elements( 1, 1 ); tIdxs indices ( 1, 1 );
typedef boost::permutation_iterator_generator< tEItr, tIItr >::type tPItr;
tPItr begin = boost::make_permutation_iterator( elements.begin(), indices.begin() );
int val = *begin;
return 0; }
error C2440: 'initializing' : cannot convert from 'struct boost::detail::iterator_traits_::undefined<void>' to 'int' Source or target has incomplete type
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
I've discovered the difference between the http://www.boost.org/libs/utility/permutation_iterator.htm example and the http://www.boost.org/libs/utility/iterator_adaptor_test.cpp test code is that the former (along with the example below) use vector<int> as the element_range_type, while the latter uses deque<int>. In my environment, permutation iterator works when used with deques but doesn't compile using vector as exhibited below. I've copied the test case and replaced deque with vector reproducing the problem.
Again the compiler complains about "struct boost::detail::iterator_traits_::undefined<void>". Since Toon says that
From: "Jeff Flinn - wwnet"
below code works with with gcc-2.95.3 as well as gcc-3.0.3, does any one know of MSVC vector issues that could be the source of this problem? I will try this using MSVC and STLPORT this evening on another machine to see if the problem persists.
A possible cause of this problem is that vector iterators are plain pointers in MSVC 6, and iterator_traits doesn't handle pointers on this compiler (no partial specialization.)
On Tue, 19 Feb 2002, Peter Dimov wrote: pdimov> pdimov> A possible cause of this problem is that vector iterators are plain pointers pdimov> in MSVC 6, and iterator_traits doesn't handle pointers on this compiler (no pdimov> partial specialization.) That sounds right, in which case, the workaround is to avoid using the template parameter defaults of iterator_adaptor. This can be done by replacing the use of projection_iterator_generator and make_permutation_iterator() with a direct use of iterator_adaptor and permutation_iterator_policies and explicitly fill in all the parameters of iterator_adaptor. Cheers, Jeremy ---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
pdimov> pdimov> A possible cause of this problem is that vector iterators are plain pointers pdimov> in MSVC 6, and iterator_traits doesn't handle pointers on this compiler (no pdimov> partial specialization.)
That sounds right, in which case, the workaround is to avoid using the template parameter defaults of iterator_adaptor. This can be done by replacing the use of projection_iterator_generator and make_permutation_iterator() with a direct use of iterator_adaptor and permutation_iterator_policies and explicitly fill in all the parameters of iterator_adaptor.
Thanks, I'll look into directly using iterator adaptor. You might note the issue with MSVC vector in the documentation for permutation_iterator. Jeff
Jeff Flinn - wwnet wrote:
pdimov> pdimov> A possible cause of this problem is that vector iterators are
plain pointers
pdimov> in MSVC 6, and iterator_traits doesn't handle pointers on this
compiler (no
pdimov> partial specialization.)
That sounds right, in which case, the workaround is to avoid using the template parameter defaults of iterator_adaptor. This can be done by replacing the use of projection_iterator_generator and make_permutation_iterator() with a direct use of iterator_adaptor and permutation_iterator_policies and explicitly fill in all the parameters of iterator_adaptor.
Thanks, I'll look into directly using iterator adaptor. You might note the issue with MSVC vector in the documentation for permutation_iterator. Good idea,
Jeremy shall I add a 'portability' note in the iterator_adaptor documentation ? (otherwise, I will at least do it in the permutation_iterator doc)
That would be great. Thanks, Jeremy On Wed, 20 Feb 2002, Toon Knapen wrote: toon.k> toon.k> toon.k> Jeremy shall I add a 'portability' note in the iterator_adaptor toon.k> documentation ? toon.k> (otherwise, I will at least do it in the permutation_iterator doc) ---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
On Tue, 19 Feb 2002, Peter Dimov wrote: pdimov> pdimov> A possible cause of this problem is that vector iterators are plain pointers pdimov> in MSVC 6, and iterator_traits doesn't handle pointers on
pdimov> partial specialization.)
That sounds right, in which case, the workaround is to avoid using
template parameter defaults of iterator_adaptor. This can be done by replacing the use of projection_iterator_generator and make_permutation_iterator() with a direct use of iterator_adaptor and permutation_iterator_policies and explicitly fill in all the
--- In Boost-Users@y..., Jeremy Siek
iterator_adaptor.
Cheers, Jeremy
-------------------------------------------------------------------- -- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@o... C++ Booster (http://www.boost.org) office phone: (812) 855-3608 -------------------------------------------------------------------- --
It's a pain with ANY iterator adaptors over plain pointer. MSVC can't deduce T from T*. And there is no workaround. You only choice is to explicetly say to adaptor what a retulting value type is. Gennadiy.
participants (5)
-
Jeff Flinn - wwnet
-
Jeremy Siek
-
Peter Dimov
-
rogeeff
-
Toon Knapen