Hi,
Take this code:
#include
#include
#include
#include <map>
#include <iostream>
#include <string>
using namespace std;
using namespace boost::assign;
const unsigned long USER = 0x0001;
const unsigned long ADMINISTRATOR = 0x0004;
const unsigned long ALL = USER + ADMINISTRATOR;
typedef map item_permissions_t;
typedef map module_permissions_t;
int main()
{
map permission_table = map_list_of
("Module1", map_list_of
("Item1", map_list_of
("Feature1", ALL)
("Feature2", ADMINISTRATOR)
)
("Item2", map_list_of
("Feature1", ALL)
("Feature2", ALL)
("Feature3", ADMINISTRATOR)
("Feature4", ADMINISTRATOR)
)
);
cout << "modules: " << permission_table.size() << "\n";
cout << "items of module 'Module1': " <<
permission_table["Module1"].size() << "\n";
cout << "features of item 'Item2' of module 'Module1': " <<
permission_table["Module1"]["Item2"].size() << "\n";
cout << "permissions of feature 'Feature4' of item 'Item2' of "
"module 'Module1': " <<
permission_table["Module1"]["Item2"]["Feature4"] << "\n";
}
It compiles fine with VC 7.1. However g++ 3.3 and 3.4
(both on Linux) refuse to compile it.
See the error message (excerpt):
sample.cpp:36: instantiated from here
/usr/include/c++/3.4/bits/stl_pair.h:90: error: call of overloaded
`map(const boost::assign_detail::generic_list > > >&)' is ambiguous
/usr/include/c++/3.4/bits/stl_map.h:166: note: candidates are:
std::map<_Key, _Tp, _Compare, _Alloc>::map(const std::map<_Key, _Tp,
_Compare, _Alloc>&) [with _Key = std::string, _Tp = item_permissions_t,
_Compare = std::lessstd::string, _Alloc = std::allocator >]
/usr/include/c++/3.4/bits/stl_map.h:156: note:
std::map<_Key, _Tp, _Compare, _Alloc>::map(const _Compare&, const typename
std::_Rb_tree<_Key, std::pair,
std::_Select1st >, _Compare,
_Alloc>::allocator_type&) [with _Key = std::string, _Tp =
item_permissions_t, _Compare = std::lessstd::string, _Alloc =
std::allocator >]
the command line is:
g++-3.4 -I ../boost_1_32_0/ sample.cpp -o sample
Any ideas of what is going on here?
Regards,
Josue Gomes