jeudi 1 mars 2018

Compact way to have multiple 'using std::foo' statements on one line?

Based on advice here, I'm avoiding using namespace std;. However, I have been adding some functions individually, as in:

using std::cout;
using std::cin;
using std::setw;
using std::setprecision;

Is there an efficient/elegant shortcut to state all of this on one line? I know I could do:

using std::cout; using std::cin; using std::setw; using std::setprecision;

but that is not particularly efficient/elegant. I tried the following, in the spirit of how it works when defining variables:

using std::cout, std::cin, std::setw, std::setprecision;

But my compiler throws an exception.

Aucun commentaire:

Enregistrer un commentaire