Boost logo

Boost Users :

Subject: [Boost-users] Strange error while using BOOST_FOREACH
From: John M. Dlugosz (mpbecey7gu_at_[hidden])
Date: 2012-03-11 05:56:16


I used BOOST_FOREACH with a collection whose iterator is derived from
boost::iterator_adaptor. I got this:

7>E:\boost_1_47\boost/range/iterator.hpp(63): error C2039: 'type' : is not a member of
'boost::mpl::eval_if_c<C,F1,F2>'
7> with
7> [
7> C=true,
7> F1=boost::range_const_iterator<VSeeClient_list>,
7> F2=boost::range_mutable_iterator<const type>
7> ]
7> E:\boost_1_47\boost/foreach.hpp(670) : see reference to class template
instantiation 'boost::range_iterator<C>' being compiled
7> with
7> [
7> C=const type
7> ]
7> AutoPerformance\APSystem.cpp(224) : see reference to function template
instantiation 'boost::foreach_detail_::auto_any<T>
boost::foreach_detail_::begin<VSeeClient_list,boost::mpl::false_>(boost::foreach_detail_::auto_any_t,boost::foreach_detail_::type2type<VSeeClient_list,C>
*,boost::mpl::false_ *)' being compiled
7> with
7> [
7> T=VSeeClient_list::iterator,
7> C=boost::mpl::false_
7> ]

The error points here:
     template< typename C >
     struct range_iterator
     {
         typedef BOOST_RANGE_DEDUCED_TYPENAME
             mpl::eval_if_c< is_const<C>::value,
                             range_const_iterator< typename remove_const<C>::type >,
                             range_mutable_iterator<C> >::type type;
     };

Now a little looking through the manual tells me that mpl::eval_if_c::type will be one of
the two metafunctions, so it should not disappear completely.

I don't believe I missed anything from the iterator code: the Value type is given as the
3rd template argument to the iterator_adaptor, so that should set up any metafunctions
needed to find the iterator's type, right?

I'm compiling using MS Visual Studio 10.

—John


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net