Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-03-28 19:50:26


----- Original Message -----
From: <rwgk_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, March 28, 2001 6:50 PM
Subject: [boost] Re: BPL: error compiling due to name class on 'modulus' in
classes.hpp

> What about this in a header file:
>
> #include <iostream>
>
> template <class T>
> class foo {
> public:
> foo(const T& x) {
> using namespace std;
> cout << "a new foo with " << x << endl;
> }
> };
>
> Is this form, too?

This example is not so egregious (I should have said that using-directives
at namespace scope in a header are bad form), but beware: there are some
surprising cases where names in templates are not found through
using-directives. It's much better to stick with using-declarations, e.g.
  using std::cout; using std::endl;

-Dave


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