[BOOST_FOREACH] ne marche pas
slt à toute la communauté,
beh voilà j'ai un problème pas très simple. Dans le cadre d'un project j'ai écris une classe défini à peu près comme suit:
Code:
1 2 3 4 5 6 7 8 9 10 11
|
class Scan
{
private:
std::vector< LaserRowSet > pointList; //!< stores all the points
unsigned int pointCount; //!< buffers the number of points
bool pointMemoryResponsability;
public:
Scan(TimeIndex t);
void add(Point *point, unsigned int laserRow=0, float yaw=0);
} |
j'ai aussi défini une classe iterator pour itérer sur mes éléments avec les fonctions:
Code:
1 2 3
|
iterator begin(); //!< get Iterator that points to the first Point, i.e. the first Point in the first laser row
iterator end(); |
.
Je peux donc ajouter des points dans ma classe en faisant tout simplement:
Code:
1 2 3 4
|
Scan s1(0);
Point p1(2,2,2);
s1.add(&p1, 5); |
Maintenant je veux afficher tous les points contenus dans mon objet scan, pour cela je fais:
Code:
1 2 3 4 5 6 7
|
Scan::iterator s1it = s1.begin();
for (s1it = s1.begin(); s1it != s1.end(); s1it++){
Point *pt = *s1it;
cout << "Point:" << *pt;
ptCount++;
} |
ca marche à merveille. Le problème est, je veux en fait utiliser boost_foreach, mais ca na marche pas:
Code:
1 2 3 4
|
BOOST_FOREACH(Point* pt, s1){
cout << "Point:" << *pt;
} |
Je n'ai vraiment pas grande idée où sa coince. Quelqu'un m'a parlé d'iterator adaptator mais je n'ai aucune idée de comment on l'utilise.
Je travaille avec Eclipse sous linux et voilà l'érreur que j'ai:
Code:
1 2 3 4 5 6 7 8 9
|
Scan.cpp:201: instantiated from here
/usr/include/boost/range/const_iterator.hpp:36: error: no type named const_iterator in class Scan
/usr/include/boost/foreach.hpp: In function typename boost::foreach_detail_::foreach_reference<T, C>::type boost::foreach_detail_::deref(const boost::foreach_detail_::auto_any_base&, boost::foreach_detail_::type2type<T, C>*) [with T = Scan, C = mpl_::bool_<false>]:
Scan.cpp:201: instantiated from here
/usr/include/boost/foreach.hpp:636: error: invalid initialization of non-const reference of type Point*& from a temporary of type Point*
make[1]: Leaving directory `/home/simo/code/DataContainers3D'
make[1]: *** [debug/Scan.o] Error 1
make: *** [debug] Error 2 |
J'attends impatienment vos suggestions et merci d'avance.
PS: désolé des quelques fautes, j'écris avec clavier allemand.