Boost logo

Boost :

From: Paul A Bristow (pbristow_at_[hidden])
Date: 2005-12-21 08:49:38


| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]] On Behalf Of Dirk Moermans
| Sent: 20 December 2005 21:27
| To: boost_at_[hidden]
| Subject: [boost] asio review
| it would improve readability if you would omit the boost::asio
| namespace throughout the tutorial. Everybody knows the library-name
| when reading the tutorial. adding a line "use namespace::boost::asio"
| in the beginning is sufficient.

I would make a slightly different recommendation - and it applies to all
code which has 'educational' intent (as opposed to writing it quickly and

IMO the clearest way is to LIST the bits that are being demonstrated
explictly with using statements (rather than a use namespace), for example
if we were trying to introduce iostreams for the first time

#include <iostream>
        using std::cout;
        using std::cin;
        using std::endl;

will make clear which functions are being used,

and indeed include info on where they are from,

and reduces the risk of unexpected effects from a 'global' using namespace

If there is a chance of ambiguity, then placing the using statement close to
(first) use may be best, for example:

using std::tr1::cbrt; // Convenient to avoid getting global ::cbrt by
cout << cbrt(27.) << endl;

If it is just a reminder or aside, of why a file is being included, then

then #include <iostream> // for cout, endl...

might be more concise.


Paul A Bristow
Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
Phone and SMS text +44 1539 561830, Mobile and SMS text +44 7714 330204
mailto: pbristow_at_[hidden]

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