I'm using a lot of the std::chrono library and my code is becoming quite verbose with things like std::chrono::x::y etc.
I do not want to use using namespace std; because this potentially shadows a lot of things in my program.
That said if I have using namespace std::chrono, now I don't have to type chrono at all. I'd prefer to specify things at that level e.g. then I can fully qualify with e.g. chrono::microseconds. I don't want to simply specify microseconds.
My class where I'd like to use this looks something like this
namespace MyNamespace {
class MyClass {
// lots of std::chrono stuff
};
}
I've tried:
using namespace chrono = std::chrono(inside the class)
Results in
error: expected nested-name-specifier before ‘namespace’
using namespace chrono = std::chrono;
^ This one is actually perplexing to me, searching for it usually yields results for those with syntax errors but the program compiles fine without this line.
using chrono = std::chrono;(same result whether inside class or outside class)
Results in:
error: ‘chrono’ in namespace ‘std’ does not name a type
using chrono = std::chrono;
using namespace chrono = std::chrono(outside class, withinMyNameSpace)
Results in:
error: ‘chrono’ is not a namespace-name
using namespace chrono = std::chrono;
^~~~~~