Today I learned: C++ does not have a single one-size-fits-all way to bring an arbitrary name into the current scope. It has three:
using a::b; works anywhere but only for certain names
using b = a::b; works anywhere but only for types, and sometimes you have to template it!!
namespace b = a::b; only works at namespace scope and only for namespaces
I never realized that was an issue before. Now I have some code that looks like this:
35 36 37 38 39 40 41 42 43 44 45
using Magnum::Math::operator""_degf;
using Magnum::Matrix3;
using Magnum::Matrix4;
using Magnum::Renderer;
using BlendFunction = Magnum::Renderer::BlendFunction;
using BlendEquation = Magnum::Renderer::BlendEquation;
namespace SceneGraph = Magnum::SceneGraph;
namespace Text = Magnum::Text;
using Magnum::Vector2;
using Magnum::Vector2i;
using Magnum::Vector3;
Look, the system you're suggesting is quite literally worse than what I outlined in the first post. I can deal with the current system. I'm not going to do weird nonsense with macros just to avoid the current system.
I don't think there are any proposals to change namespace aliases, type aliases, or using-declarations (other than the just voted-in rewording of inheriting constructors)
If you have a concrete idea (the motivating example is nice, but what syntax would you like to see, precisely?), float it on std-proposals as outlined in https://isocpp.org/std/submit-a-proposal .
What's wrong with that code? You don't like the way it looks? I also don't see the issue with having 3, well really 2 ways. The distinction for namespaces should exist IMO. Then the only thing that really doesn't work is function aliasing using swapo = std::swap. You just use the first "using" if you don't want to change the name and the other "using" if you do.
What is BlendFunction? An enum? You should be able to use using Magnum::Renderer::BlendFunction;.
1 2
using Magnum::Matrix3; // to use in current scope
using Matrix3x3 = Magnum::Matrix3; // to give an alias of something in current scope
I don't see any way this can be merged into one, unless you just get rid of the first option. Then people will be complaining about how they have to retype the same name twice.
@goosestuf: ideally it shouldn't matter what something is. There should be one syntax for bringing a name into the current scope, regardless of what that name refers to. IMO using a::b; and using c = a::b; syntax should work for all things and in all scopes. Templates shouldn't complicate things.