Boost logo

Boost :

From: Volker Vieth (wusel1311_at_[hidden])
Date: 2005-02-28 11:30:02


Hi,

using multi_index_container I've got strange errors. Simple source code
leaned on official examples doesn't compile. Hardly modified code that seems
to be equivalent does compile however. I've reduced it to two examples.

I'm using Visual C++ .NET 7.09466 (i.e. cl.exe 13.00.9466) with boost 1.32.0
under Win XP.

This first example is a shortened version of
boost_1_32_0\libs\multi_index\example\basic.cpp. It reveals 4 subversions,
but 2 of them only compile without erros. Why the other don't?

01 #include <boost/multi_index_container.hpp>
02 #include <boost/multi_index/member.hpp>
03 #include <boost/multi_index/ordered_index.hpp>
04 #include <string>
05
06 using boost::multi_index_container;
07 using namespace ::boost;
08 using namespace boost::multi_index;
09
10
11 struct employee
12 {
13 int id;
14 std::string name;
15 int age;
16
17 employee(int id_,std::string name_,int
age_):id(id_),name(name_),age(age_){}
18 };
19
20
21 struct id{};
22 struct name{};
23 struct age{};
24
25
26 typedef multi_index_container<
27 employee,
28 indexed_by<
29 ordered_unique<
30 tag<id>, BOOST_MULTI_INDEX_MEMBER(employee,int,id)>,
31 ordered_non_unique< //remove for versions C, D
32 tag<name>,BOOST_MULTI_INDEX_MEMBER(employee,std::string,name)>,
33 ordered_non_unique<
34 tag<age>, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> >
35 > employee_set;
36
37
38 //use exact one of following versions, remove the other lines
39
40 //version A: does NOT compile
41 //causes basic.cpp(42) : error C2976: 'boost::multi_index::index' : too
few template arguments
42 typedef employee_set::index<id>::type employee_set_by_id;
43
44 //version B: DOES compile
45 typedef index<employee_set,id >::type employee_set_by_id;
46 typedef index<employee_set,age>::type employee_set_by_age;
47
48 //remove the name index (lines 31, 32) for following versions
49
50 //version C: DOES compile
51 typedef index<employee_set,id >::type employee_set_by_id;;
52
53 //version D: does NOT compile
54 //causes
...\include\boost-1_32\boost\mpl\vector\aux_\preprocessed\no_ctps\vector10.hpp(398)
:
55 // error C2039: 'item3' : is not a member of
'boost::mpl::vector2<T0,T1>'
56 typedef index<employee_set,age>::type employee_set_by_age;

My second example consists of 2 tiny programs. The former compile fine.
Using the qualified name should do the same, but outputs
...\include\boost-1_32\boost\multi_index_container.hpp(60) : error C2039:
'multi_index_node_type' : is not a member of 'boost::detail'
Where's the difference?

60 #include <boost/multi_index_container.hpp>
61 #include <boost/multi_index/ordered_index.hpp>
62
63 using boost::multi_index_container;
64
65 int main( int argc, char* argv[] )
66 {
67 multi_index_container< int > mic;
68 return 0;
69 }

70 #include <boost/multi_index_container.hpp>
71 #include <boost/multi_index/ordered_index.hpp>
72
73 int main( int argc, char* argv[] )
74 {
75 boost::multi_index_container< int > mic;
76 return 0;
77 }

-- 
DSL Komplett von GMX +++ Supergünstig und stressfrei einsteigen!
AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk