Bonjour,

J'ai très récemment téléchargé Boost pour tester, on ne m'en disais que du bien. Après un petit tour dans la doc, et donc après avoir vu des choses plutot impressionnantes, je me suis mis à réécrire un projet C++ avec des conteneurs intrusifs (le projet était avant avec std::list).

Et il se trouve que ca ne compile pas...

Le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
    class EqualRefSystem : public boost::intrusive::list_base_hook< boost::intrusive::link_mode<boost::intrusive::normal_link> >
 
    {
 
        public:
 
            //! Constructor
 
            EqualRefSystem()
 
            :Target(0),RefCount(0) {}
 
 
 
            //! Destructor
 
            /** Safe destructor : all references and target are reseted. **/
 
            virtual ~EqualRefSystem()
 
            {
 
                resetTarget();
 
                unlink();
 
            }
 
 
 
            //! Returns the targeted object
 
            /** \return A pointer to the object targeted by this EqualRefSystem. **/
 
            EqualRefSystem* getTarget() const
 
            { return Target; }
 
 
 
            //! Sets the target
 
            /** \param tgt : The new target. 0 means 'no target'. If tgt == this, the target is set to 0. **/
 
            void setTarget(EqualRefSystem* tgt)
 
            {
 
                if(tgt == Target) return;
 
                if(tgt == this) tgt = 0;
 
                if(Target) Target->dereference(this);
 
                Target = tgt;
 
                if(Target) Target->reference(this);
 
            }
 
 
 
            //! Resets the target
 
            /** This function is a synonym for setTarget(0). **/
 
            void resetTarget()
 
            {
 
                if(Target) Target->dereference(this);
 
                Target = 0;
 
            }
 
 
 
            //! Returns whether a target is set or not
 
            /** This function is a synonym for (getTarget() != 0).
 
                \return True if a target is set, else false. **/
 
            bool hasTarget() const
 
            { return Target != 0; }
 
 
 
            //! Unlink from all objects which targets this one
 
            /** This function resets the target of all objects targeting this EqualRefSystem. **/
 
            void unlink()
 
            {
 
                while(!ReferencedBy.empty()) ReferencedBy.begin()->resetTarget();
 
                RefCount = 0;
 
            }
 
 
 
            //! Returns the number of objects targeting this one
 
            /** \return The number of objects targeting this EqualRefSystem. Constant-time. **/
 
            unsigned int getNumberOfReferences() const
 
            { return RefCount; }
 
 
 
        private:
 
            //! Reference an object in this EqualRefSystem
 
            void reference(const EqualRefSystem* toRef)
 
            {
 
                if(!toRef || toRef == this) return;
 
                ReferencedBy.push_back(*toRef);
 
                RefCount++;
 
            }
 
 
 
            //! Dereference an object from this EqualRefSystem
 
            void dereference(const EqualRefSystem* toDeref)
 
            {
 
                if(!toDeref || toDeref == this) return;
 
                ReferencedBy.erase(ReferencedBy.iterator_to(*toDeref));
 
                RefCount--;
 
            }
 
 
 
            //! Targeted object
 
            EqualRefSystem* Target;
 
 
 
            //! Objects that reference this EqualRefSystem
 
            boost::intrusive::list<EqualRefSystem,
 
                    boost::intrusive::list_base_hook< boost::intrusive::link_mode<boost::intrusive::normal_link> >,
 
                    boost::intrusive::constant_time_size<false> > ReferencedBy;
 
 
 
            //! Number of references
 
            unsigned int RefCount;
 
    };
MinGW GCC 4.4.0 me sort:

-------------- Build: Debug in equalrefsystem ---------------



Compiling: main.cpp

In file included from D:\Boost/boost/intrusive/list_hook.hpp:22,

from D:\Boost/boost/intrusive/list.hpp:20,

from D:\ReferenceSystem\equalrefsystem\/src\EqualRefSystem.h:3,

from D:\ReferenceSystem\equalrefsystem\main.cpp:5:

D:\Boost/boost/intrusive/options.hpp: In instantiation of 'boost::intrusive::do_pack<boost::intrusive::list_defaults<base::EqualRefSystem>, boost::intrusive::list_base_hook<boost::intrusive::link_mode<(boost::intrusive::link_mode_type)0u>, boost::intrusive::none, boost::intrusive::none> >':

D:\Boost/boost/intrusive/options.hpp:639: instantiated from 'boost::intrusive::pack_options<boost::intrusive::list_defaults<base::EqualRefSystem>, boost::intrusive::list_base_hook<boost::intrusive::link_mode<(boost::intrusive::link_mode_type)0u>, boost::intrusive::none, boost::intrusive::none>, boost::intrusive::constant_time_size<false>, boost::intrusive::none, boost::intrusive::none, boost::intrusive::none, boost::intrusive::none, boost::intrusive::none, boost::intrusive::none, boost::intrusive::none, boost::intrusive::none, boost::intrusive::none>'

D:\Boost/boost/intrusive/list.hpp:1414: instantiated from 'boost::intrusive::make_list<base::EqualRefSystem, boost::intrusive::list_base_hook<boost::intrusive::link_mode<(boost::intrusive::link_mode_type)0u>, boost::intrusive::none, boost::intrusive::none>, boost::intrusive::constant_time_size<false>, boost::intrusive::none>'

D:\Boost/boost/intrusive/list.hpp:1447: instantiated from 'boost::intrusive::list<base::EqualRefSystem, boost::intrusive::list_base_hook<boost::intrusive::link_mode<(boost::intrusive::link_mode_type)0u>, boost::intrusive::none, boost::intrusive::none>, boost::intrusive::constant_time_size<false>, boost::intrusive::none>'

D:\ReferenceSystem\equalrefsystem\/src\EqualRefSystem.h:106: instantiated from here

D:\Boost/boost/intrusive/options.hpp:577: error: no class template named 'pack' in 'class boost::intrusive::list_base_hook<boost::intrusive::link_mode<(boost::intrusive::link_mode_type)0u>, boost::intrusive::none, boost::intrusive::none>'

In file included from D:\ReferenceSystem\equalrefsystem\main.cpp:5:

D:\ReferenceSystem\equalrefsystem\/src\EqualRefSystem.h: In member function 'void base::EqualRefSystem::unlink()':

D:\ReferenceSystem\equalrefsystem\/src\EqualRefSystem.h:74: error: 'class boost::intrusive::list<base::EqualRefSystem, boost::intrusive::list_base_hook<boost::intrusive::link_mode<(boost::intrusive::link_mode_type)0u>, boost::intrusive::none, boost::intrusive::none>, boost::intrusive::constant_time_size<false>, boost::intrusive::none>' has no member named 'empty'

D:\ReferenceSystem\equalrefsystem\/src\EqualRefSystem.h:74: error: 'class boost::intrusive::list<base::EqualRefSystem, boost::intrusive::list_base_hook<boost::intrusive::link_mode<(boost::intrusive::link_mode_type)0u>, boost::intrusive::none, boost::intrusive::none>, boost::intrusive::constant_time_size<false>, boost::intrusive::none>' has no member named 'begin'

D:\ReferenceSystem\equalrefsystem\/src\EqualRefSystem.h: In member function 'void base::EqualRefSystem::reference(const base::EqualRefSystem*)':

D:\ReferenceSystem\equalrefsystem\/src\EqualRefSystem.h:88: error: 'class boost::intrusive::list<base::EqualRefSystem, boost::intrusive::list_base_hook<boost::intrusive::link_mode<(boost::intrusive::link_mode_type)0u>, boost::intrusive::none, boost::intrusive::none>, boost::intrusive::constant_time_size<false>, boost::intrusive::none>' has no member named 'push_back'

D:\ReferenceSystem\equalrefsystem\/src\EqualRefSystem.h: In member function 'void base::EqualRefSystem::dereference(const base::EqualRefSystem*)':

D:\ReferenceSystem\equalrefsystem\/src\EqualRefSystem.h:96: error: 'class boost::intrusive::list<base::EqualRefSystem, boost::intrusive::list_base_hook<boost::intrusive::link_mode<(boost::intrusive::link_mode_type)0u>, boost::intrusive::none, boost::intrusive::none>, boost::intrusive::constant_time_size<false>, boost::intrusive::none>' has no member named 'erase'

D:\ReferenceSystem\equalrefsystem\/src\EqualRefSystem.h:96: error: 'class boost::intrusive::list<base::EqualRefSystem, boost::intrusive::list_base_hook<boost::intrusive::link_mode<(boost::intrusive::link_mode_type)0u>, boost::intrusive::none, boost::intrusive::none>, boost::intrusive::constant_time_size<false>, boost::intrusive::none>' has no member named 'iterator_to'

Process terminated with status 1 (0 minutes, 2 seconds)

6 errors, 0 warnings
J'ai regardé la source (list.hpp) mais je n'ai pas compris d'où venait l'erreur.
Je précise, le fichier boost/intrusive/list.hpp est bien inclus dans le code ci-dessus.

Ce pourquoi je vous demande votre aide.

Merci d'avance,

~Darktib