Dave,
Here is a small example which produces errors:
#include <iostream>
#include <functional>
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
using namespace boost;
template<class T>
struct wrap{};
struct dispatcher
{
template<class Seq>
void dispatch()
{
int i=0;
mpl::for_eachmpl::_1
::type>(bind<void>(*this, i, _1));
cout << "I did: " << i << " iterations\n";
}
template<class T>
void operator()(int& i, wrap<T>)const
{
cout <<"pos: " << i << ", type: " << typeid(T).name() <<
'\n';
++i;
}
};
#include <string>
int main(int argc, char* argv[])
{
dispatcher d;
d.dispatch >();
}
Sorry for so many headers, some of them are not required...
Visual C++ 2005 blames:
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\map\aux_\preprocessed\plain\map10.hpp(88)
: error C2825: 'P2': must be a class or namespace when followed by '::'
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\aux_\preprocessed\plain\map.hpp(68) : see
reference to class template instantiation 'boost::mpl::map3' being
compiled
with
[
P0=int,
P1=long,
P2=double
]
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\aux_\has_tag.hpp(20) : see reference to
class template instantiation 'boost::mpl::map' being compiled
with
[
T0=int,
T1=long,
T2=double
]
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\sequence_tag.hpp(112) : see reference to
class template instantiation 'boost::mpl::aux::has_tag<T>' being compiled
with
[
T=boost::mpl::map
]
c:\program files (x86)\boost\boost_1_33_1\boost\mpl\clear.hpp(29) :
see reference to class template instantiation
'boost::mpl::sequence_tag<Sequence>' being compiled
with
[
Sequence=boost::mpl::map
]
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\transform.hpp(113) : see reference to
class template instantiation 'boost::mpl::clear<Sequence>' being compiled
with
[
Sequence=boost::mpl::map
]
c:\program files (x86)\boost\boost_1_33_1\boost\mpl\eval_if.hpp(41)
: see reference to class template instantiation
'boost::mpl::transform1' being compiled
with
[
P1=boost::mpl::map,
P2=wrapboost::mpl::_1,
P3=boost::mpl::na
]
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\transform.hpp(138) : see reference to
class template instantiation 'boost::mpl::eval_if' being compiled
with
[
C=boost::mpl::or_boost::mpl::na,boost::mpl::is_lambda_ex
pressionboost::mpl::_1>,boost::mpl::not_boost::mpl::_1>>>,
F1=boost::mpl::transform1,wrap,boost::mpl::na>,
F2=boost::mpl::transform2,wrap,boost::mpl::na,boost::mpl::na>
]
d:\projects\cpp_projects\cpptests\messagewrappertests\main2.cpp(26)
: see reference to class template instantiation
'boost::mpl::transform' being compiled
with
[
Seq1=boost::mpl::map,
Seq2OrOperation=wrapboost::mpl::_1
]
d:\projects\cpp_projects\cpptests\messagewrappertests\main2.cpp(81)
: see reference to function template instantiation 'void
dispatcher::dispatch>(void)' being compiled
with
[
T0=int,
T1=long,
T2=double
]
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\map\aux_\preprocessed\plain\map10.hpp(88)
: error C2039: 'first' : is not a member of '`global namespace''
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\map\aux_\preprocessed\plain\map10.hpp(89)
: error C2146: syntax error : missing ',' before identifier 'first'
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\map\aux_\preprocessed\plain\map10.hpp(89)
: error C2825: 'P2': must be a class or namespace when followed by '::'
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\map\aux_\preprocessed\plain\map10.hpp(89)
: error C2039: 'second' : is not a member of '`global namespace''
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\map\aux_\preprocessed\plain\map10.hpp(90)
: error C2146: syntax error : missing ',' before identifier 'second'
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\map\aux_\preprocessed\plain\map10.hpp(91)
: error C2977: 'boost::mpl::m_item' : too many template arguments
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\map\aux_\item.hpp(79) : see declaration
of 'boost::mpl::m_item'
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\map\aux_\preprocessed\plain\map10.hpp(92)
: error C2955: 'boost::mpl::m_item' : use of class template requires
template argument list
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\map\aux_\item.hpp(79) : see declaration
of 'boost::mpl::m_item'
c:\program files
(x86)\boost\boost_1_33_1\boost\mpl\map\aux_\preprocessed\plain\map10.hpp(92)
: error C2504: 'boost::mpl::m_item' : base class undefined
c:\program files (x86)\boost\boost_1_33_1\boost\mpl\clear.hpp(31) : error
C2504: 'boost::mpl::clear_impl<Tag>::apply<Sequence>' : base class undefined
with
[
Tag=boost::mpl::aux::sequence_tag_impl::result2_>::type
]
and
[
Sequence=boost::mpl::map
]
c:\program files (x86)\boost\boost_1_33_1\boost\mpl\transform.hpp(113) :
error C2039: 'type' : is not a member of 'boost::mpl::clear<Sequence>'
with
[
Sequence=boost::mpl::map
]
c:\program files (x86)\boost\boost_1_33_1\boost\mpl\transform.hpp(113) :
error C3203: 'type' : unspecialized class template can't be used as a
template argument for template parameter 'Sequence', expected a real type
c:\program files (x86)\boost\boost_1_33_1\boost\mpl\transform.hpp(113) :
error C2039: 'type' : is not a member of 'boost::mpl::clear<Sequence>'
with
[
Sequence=boost::mpl::map
]
c:\program files (x86)\boost\boost_1_33_1\boost\mpl\transform.hpp(113) :
error C3203: 'type' : unspecialized class template can't be used as a
template argument for template parameter 'Sequence', expected a real type
Many thanks,
Ovanes
P.S. I am trying to make a map with 150 elements. I posted on this issue 2
posts, can you please take a look?
http://lists.boost.org/boost-users/2006/10/23057.php
-----Original Message-----
From: David Abrahams [mailto:dave@boost-consulting.com]
Sent: Thursday, November 02, 2006 10:05 PM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] [mpl::map & mpl::transform] Problems
usingmpl::map in mpl::for_each
"Ovanes Markarian" writes:
Hello,
I have some slightly different code, which is presented in C++
Template Metaprogramming book to use the mpl::for_each function:
mpl::for_each< mpl::transform >::type
(dispatcher_type());
mpl::for_each >(dispatcher_type());
would be simpler
The deviation from the book is that my seq it not mpl::vector<...>,
but mpl::map<...>
In the docs is written, that mpl::transform operates on Forward
Sequence. In the doc of forward sequence is stated that mpl::map is a
model of it.
The last release of mpl::map had some considerable bugs. Have you tried the
latest version from the CVS HEAD (or RC_1_34_0)?
Unfortunately this code does not compile. I could transform the map to
vector, but I would not like doing it, since that would cost compile
time and slow down the compilation. Is it a known issue or should not
I expect map to work with transform?
The code could "not compile" for many other reasons than that "map doesn't
work with transform." Have you tried to compile
typedef mpl::transform >::type x;
I also tried using itertors on seq, but that did not help.
I think we'll need a lot more detail to be able to help you.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users