Opened 13 years ago
Last modified 12 years ago
#3874 new Bugs
[map0 / insert] inserting into map0 does not work without including map10.hpp
Reported by: | Owned by: | Aleksey Gurtovoy | |
---|---|---|---|
Milestone: | Boost 1.42.0 | Component: | mpl |
Version: | Boost 1.41.0 | Severity: | Problem |
Keywords: | mpl map0 insert | Cc: |
Description
The following does not compile on MSVC9:
#include <boost/mpl/insert.hpp> #include <boost/mpl/map/map0.hpp> #include <boost/mpl/pair.hpp> typedef boost::mpl::insert< boost::mpl::map0<>, boost::mpl::pair< void, void > >::type map1_type; typedef boost::mpl::insert< map1_type, boost::mpl::pair< int, int > >::type map2_type; int main() { }
The compiler output is
1>------ Build started: Project: test, Configuration: Debug Win32 ------ 1>Compiling... 1>main.cpp 1>d:\boost_1_41_0\boost\mpl\insert.hpp(32) : error C2903: 'apply' : symbol is neither a class template nor a function template 1> d:\test\main.cpp(13) : see reference to class template instantiation 'boost::mpl::insert<Sequence,Pos_or_T>' being compiled 1> with 1> [ 1> Sequence=map1_type, 1> Pos_or_T=boost::mpl::pair<int,int> 1> ] 1>d:\boost_1_41_0\boost\mpl\insert.hpp(32) : error C2039: 'apply' : is not a member of 'boost::mpl::insert_impl<boost::mpl::non_sequence_tag>' 1> d:\boost_1_41_0\boost\mpl\aux_\insert_impl.hpp(64) : see declaration of 'boost::mpl::insert_impl<boost::mpl::non_sequence_tag>' 1>d:\boost_1_41_0\boost\mpl\insert.hpp(32) : error C2955: 'boost::mpl::apply' : use of class template requires template argument list 1> d:\boost_1_41_0\boost\mpl\aux_\preprocessed\plain\apply.hpp(134) : see declaration of 'boost::mpl::apply' 1>d:\boost_1_41_0\boost\mpl\insert.hpp(32) : error C2143: syntax error : missing ',' before '<' 1>d:\test\main.cpp(13) : error C2039: 'type' : is not a member of 'boost::mpl::insert<Sequence,Pos_or_T>' 1> with 1> [ 1> Sequence=map1_type, 1> Pos_or_T=boost::mpl::pair<int,int> 1> ] 1>d:\test\main.cpp(13) : error C2146: syntax error : missing ';' before identifier 'map2_type' 1>d:\test\main.cpp(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>d:\test\main.cpp(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>Build log was saved at "file://d:\test\Debug\BuildLog.htm" 1>test - 8 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
A fix (which took me a while to figure out, since the above error message didn't give me any clues) is to include <boost/mpl/map/map10.hpp>. I think either a note should be made in the documentation for insert, the error message should be more helpful (maybe a comment in mpl/insert.hpp line 32???), or the above code should "just work".
Note:
See TracTickets
for help on using tickets.
In C++0x, the code will just work, since the typeof based implementation of mpl::map has no fixed limits. Unfortunately, with the non-typeof implementation, there is no good way to make it just work.