Instead of including a whole namespace in a given function, I like to only include the stuff I'm going to use, like:
void doStuff() {
using std::sin;
using std::cos;
...
// do stuff
}
Sometimes this list grows longer. I wanted to slim it down to the following (similar to how it's possible with variable declarations):
void doStuff() {
using std::sin, std::cos;
// do stuff
}
I was surprised to find that this was not possible
(error: expected ';' after using declaration
). Is there a reason for why the using
is defined this way? Is there another way to include a number of functions from a given namespace consisely (except doing using namespace ...;
)?