|
Boost : |
From: Henrik Kuhn (henrik.kuhn_at_[hidden])
Date: 2001-11-21 09:55:32
Hi boosters,
I'm struggling with the boost::iterator_adaptors, in detail with the
indirect_iterator stuff.
During my search in the boost group, George A. Heintzelman (message
#18183) depicted nearly the same I need. The difference is I'm using
shared pointers as the vector template argument.
I working with Borland C++ Builder 5.0 Update Pack 1 and on compiling
the following code I get the error message:
[C++ Error] compressed_pair.hpp(362): E2312 'base' is not an
unambiguous base class of 'compressed_pair<shared_ptr<foo>*,
indirect_iterator_policies>'
Is there something wrong towards my useage of the
boost::indirect_iterator_pair_generator.
Regards,
Henrik
//--------------------------------------------------------------------
#include <iostream>
#include <boost/utility.hpp>
#include <boost/smart_ptr.hpp>
#include <vector>
#include <boost/iterator_adaptors.hpp>
#pragma hdrstop
//--------------------------------------------------------------------
class foo : boost::noncopyable
{
public:
foo(const int a_) : m_a(a_) {}
int get() { return m_a; }
private:
int m_a;
};
#pragma argsused
int main(int argc, char* argv[])
{
typedef boost::shared_ptr<foo> foo_ptr_t;
typedef std::vector<foo_ptr_t> foo_ptr_vect_t;
typedef foo_ptr_vect_t::iterator vect_iterator;
typedef boost::indirect_iterator_pair_generator<
vect_iterator,
foo, foo&, const foo&,
std::random_access_iterator_tag,
foo*,
const foo*> pair_indirectors;
typedef pair_indirectors::iterator indirector;
foo_ptr_vect_t v(4);
for(std::size_t i=0; i<v.size(); ++i)
v[i].swap( foo_ptr_t(new foo(i)) );
// the following line produces an compiler error
indirector i(v.begin()),
// indirector end(v.end());
// while(i!=end)
// {
// std::cout << i->get() << '\n';
// ++i;
// }
return 0;
}
//--------------------------------------------------------------------
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk