Boost logo

Boost :

From: Michael Goldshteyn (mgoldshteyn_at_[hidden])
Date: 2005-11-23 16:09:02


"David Abrahams" <dave_at_[hidden]> wrote in message
news:ulkzlbiyw.fsf_at_boost-consulting.com...
>It's not a question of "fully using." If the vector type is
>instantiated before the parameter is fully defined, it's an error.
>Otherwise, you're OK. The forward declaration technique can be used
>legally in many scenarios.
>

The problem arises when I need an iterator - a nested typedef within vector,
which as I understand it, requires the vector's value type to be defined, so
that the vector template class, of that type, can be instantiated. For
example:

----------------------------------
Foo.h
----------------------------------
class Foo
{
...
};

----------------------------------
FooAction.h
----------------------------------
#include "Foo.h"

class FooAction
{
public:
  typedef std::list<Foo> FooList;

private:
  // The following causes us to need class Foo to be fully defined and not
just declared.
  FooList::iterator m_iFooList;
};

----------------------------------
FooContainer.h
----------------------------------
#include "Foo.h" // This is definitely needed
#include "FooAction.h" // Is this really needed?

class FooContainer
{
public:
  typedef std::list<Foo> FooList;
  typedef std::vector<FooAction> FooActionVector;

  void GetActionableFoos(FooActionVector &actions);

private:
  FooList m_listOfFoos;
};


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk