Boost logo

Boost :

From: Javier Estrada (ljestrada_at_[hidden])
Date: 2004-03-08 12:40:27


A couple of weeks ago I posted in c++ moderated:

It seems natural that if there is a <iosfwd> to forward declare the I/O
related classes, there should be a header for the classes contained in the
std namespace.

In the trenches, often times I come across classes that can be simply
defined in terms of references and pointers to other classes. An example is
defining interfaces or "protocol classes." Granted, with a small project,
using an <stdfwd> header does not provide a big advantage, but I deal with
500+ files in a framework...

I believe that the rationale is so simple that I even feel lazy about
explaining the benefits, but oh well:

// needlessly including the definition of string (or basic_string) and
vector
#include <string>
#include <vector>

class ISeek{
public:
  virtual void seek_knowledge(const std::string& token) = 0;
  virtual void seek_advice(const std::vector<std::string>& advisers) = 0;
};

// using the proposed header...
#include <stdfwd>

class ISeek{
public:
  virtual void seek_knowledge(const std::string& token) = 0;
  virtual void seek_advice(const std::vector<std::string>& advisers) = 0;
};

Please ready your darts and fire at will. I'd like to know if there is
enough support that it could fly in a proposal to the std committee.

Javier

jestrada at developeer dot com


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