When trying to use boost::indirect_iterator I am getting “int is not a class, struct, or union type”.
Can anyone see where I’m going wrong?
#include <iostream>
#include <set>
#include <boost/iterator/indirect_iterator.hpp>
// Expose the itererator if the container stores pointers.
class MyCollection
{
public:
// Iterator interface
typedef boost::indirect_iterator<int*> iterator;
iterator begin() { return objects.begin(); }
iterator end() { return objects.end(); }
private:
std::set<int*> objects;
};
int main()
{
MyCollection myCollection;
for(MyCollection::iterator iterator = myCollection.begin(); iterator != myCollection.end(); iterator++)
{
std::cout << " " << *iterator;
}
return 0;
}
It turns out you have to use: