Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-06-14 12:03:49

----- Original Message -----
From: "Beman Dawes" <bdawes_at_[hidden]>

> >In my own programs, as a matter of style I include the corresponding
> >header first, before any standard headers. This helps make sure you
> >forget to include it, and also provides a rudimentary "does this header
> >include enough things to stand alone" check. I'd like to suggest it was
> >standard practice for Boost as well.
> Interesting. I don't remember ever hearing any suggested practice for
> ordering of #includes. Do you have a simple example of an error your
> suggestion would detect? I think I understand your rationale, but an
> example might help.

FWIW, I came up with the same guideline myself. Here's an example. switching
the #include order in a.cpp obscures the bug.

==== a.hpp ====
// missing #include of <ostream>
int f(std::ostream&);

==== a.cpp ====
#include "a.hpp"
#include <ostream>

int f(std::ostream&) { ... }

Boost list run by bdawes at, gregod at, cpdaniel at, john at