Boost logo

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>*,

Is there something wrong towards my useage of the


#include <iostream>
#include <boost/utility.hpp>
#include <boost/smart_ptr.hpp>
#include <vector>
#include <boost/iterator_adaptors.hpp>
#pragma hdrstop


class foo : boost::noncopyable
    foo(const int a_) : m_a(a_) {}

    int get() { return m_a; }

    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<
        foo, foo&, const 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, gregod at, cpdaniel at, john at