By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

counting_iterator with transform_iterator ?

P: n/a
Hi all,

I'm hoping someone can tell me what is wrong with the code below.
Basically, I want to take a counting_iterator and then transform it with
a transform_iterator.

This is currently very simple, but the intended context is more elaborate.

It seems that compressed_pair is used to store the objects, but it wants
iterator_traits<> for the counting_iterator. C++ seems to have all
sorts of problems trying to figure it out. This tiny program manages to
generate over 8600 lines of errors !!

Here are some of the error messages (from gcc 2.95.4)

/usr/include/boost/type_traits/is_arithmetic.hpp:32: template
instantiation depth exceeds maximum of 17
/usr/include/boost/type_traits/is_arithmetic.hpp:32: (use
-ftemplate-depth-NN to increase the maximum)
/usr/include/boost/type_traits/is_arithmetic.hpp:32: instantiating
`boost::mpl::bool_<true>::value'
/usr/include/boost/type_traits/is_arithmetic.hpp:32: instantiated from
`boost::detail::is_arithmetic_impl<int>'

.... and so on, until much much later on:

/usr/include/boost/detail/call_traits.hpp:86: `value' is not a member of
type `boost::is_pointer<boost::counting_iterator_polici es<int> >'
/usr/include/boost/detail/call_traits.hpp:86: `value' is not a member of
type `boost::is_arithmetic<boost::counting_iterator_pol icies<int> >'
/usr/include/boost/detail/call_traits.hpp:86: template argument 2 is invalid
/usr/include/boost/detail/call_traits.hpp:86: template argument 3 is invalid

.... and finally at the very end:

/usr/include/boost/detail/compressed_pair.hpp:355: no type named
`param_type' in `struct
boost::call_traits<boost::counting_iterator_polici es<int> >'
/usr/include/boost/detail/compressed_pair.hpp:362: no type named
`param_type' in `struct
boost::call_traits<boost::counting_iterator_polici es<int> >'
/usr/include/boost/detail/compressed_pair.hpp:362: no type named
`param_type' in `struct boost::call_traits<int>'
/usr/include/boost/detail/compressed_pair.hpp:362: confused by earlier
errors, bailing out

What is wrong?

Thanks,
Paul


#include <boost/counting_iterator.hpp>
#include <functional>
#include <boost/iterator_adaptors.hpp>
using namespace boost;
struct Function : public unary_function< int, int >
{
const result_type& operator()( const argument_type& t ) const
{ return t; }
};
typedef boost::transform_iterator_generator< Function,
boost::counting_iterator_generator<int>::type
::type silly_adaptor;

int main()
{
silly_adaptor x;
return 0;
}

Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Joe
Never mind, stupid me, turns out I just needed to add the flag
-ftemplate-depth-30, and that fixed it.
Paul wrote:
Hi all,

I'm hoping someone can tell me what is wrong with the code below.
Basically, I want to take a counting_iterator and then transform it with
a transform_iterator.

This is currently very simple, but the intended context is more elaborate.

It seems that compressed_pair is used to store the objects, but it wants
iterator_traits<> for the counting_iterator. C++ seems to have all
sorts of problems trying to figure it out. This tiny program manages to
generate over 8600 lines of errors !!

Here are some of the error messages (from gcc 2.95.4)

/usr/include/boost/type_traits/is_arithmetic.hpp:32: template
instantiation depth exceeds maximum of 17
/usr/include/boost/type_traits/is_arithmetic.hpp:32: (use
-ftemplate-depth-NN to increase the maximum)
/usr/include/boost/type_traits/is_arithmetic.hpp:32: instantiating
`boost::mpl::bool_<true>::value'
/usr/include/boost/type_traits/is_arithmetic.hpp:32: instantiated from
`boost::detail::is_arithmetic_impl<int>'

... and so on, until much much later on:

/usr/include/boost/detail/call_traits.hpp:86: `value' is not a member of
type `boost::is_pointer<boost::counting_iterator_polici es<int> >'
/usr/include/boost/detail/call_traits.hpp:86: `value' is not a member of
type `boost::is_arithmetic<boost::counting_iterator_pol icies<int> >'
/usr/include/boost/detail/call_traits.hpp:86: template argument 2 is
invalid
/usr/include/boost/detail/call_traits.hpp:86: template argument 3 is
invalid

... and finally at the very end:

/usr/include/boost/detail/compressed_pair.hpp:355: no type named
`param_type' in `struct
boost::call_traits<boost::counting_iterator_polici es<int> >'
/usr/include/boost/detail/compressed_pair.hpp:362: no type named
`param_type' in `struct
boost::call_traits<boost::counting_iterator_polici es<int> >'
/usr/include/boost/detail/compressed_pair.hpp:362: no type named
`param_type' in `struct boost::call_traits<int>'
/usr/include/boost/detail/compressed_pair.hpp:362: confused by earlier
errors, bailing out

What is wrong?

Thanks,
Paul


#include <boost/counting_iterator.hpp>
#include <functional>
#include <boost/iterator_adaptors.hpp>
using namespace boost;
struct Function : public unary_function< int, int >
{
const result_type& operator()( const argument_type& t ) const
{ return t; }
};
typedef boost::transform_iterator_generator< Function,
boost::counting_iterator_generator<int>::type
>::type silly_adaptor;

int main()
{
silly_adaptor x;
return 0;
}


Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.