Search code examples
c++usingusing-declaration

c++ : comma separated list in using declaration


Why is it a bad practice to use a comma separated list in a using declaration statement in c++?

For example

using std::cout;
using std::cin;
using std::endl;

is considered better code than

using std::cout,std::cin,std::endl;

Some compiliers(gcc, for instance) even issue warnings if the code contains a comma separated list of using declarations.

Ofcourse, the best practice would be to use fully qualified names for identifiers.


Solution

  • As documented at cppreference, the form

    using declarator-list;

    is available from C++17 onwards only.

    Your compiler is probably telling you this, if you'd read the warning!