0

I searched but I could not find related question. Please correct me if I'm wrong.

In my project I use the following:

using namespace std;
using namespace sf;

I want it to be like below.

using namespace std, sf;

Thanks in advance!

uv_
  • 746
  • 2
  • 13
  • 25
CodingLab
  • 1,441
  • 2
  • 13
  • 37

2 Answers2

8

This syntax is not supported, so you'll have to keep declaring multiple using statements.

In general, though, it's considered best practice to avoid declaring using namespace at all - definitely not in headers, and preferably in the inner-most scope possible (as to not pollute too much scope with unwanted symbols.

uv_
  • 746
  • 2
  • 13
  • 25
3

I want it to be like below.

using namespace std, sf;

The syntax you're after is simply not supported by the current c++ standard.

Besides it is discouraged to import whole namespaces (at least not in header files), you may sent a request to the c++ standards committee, and see if they like to support that.


The general advice is that you should only

  • either specify exact classes you're using in your translation unit (to save typing) like using std::cout = co;
  • or to make everything clear by explicitly using fully qualified identifiers everywhere like std::cout, std::endl, etc.

The latter way is the most readable and best IMO.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190