Recently found interesting feature in c++: alias to namespace.
namespace A { int A = 5; }; namespace B = A;I wonder what is it for ... ?
blog about software development, *nix and anything that is related to that
Recently found interesting feature in c++: alias to namespace.
namespace A { int A = 5; }; namespace B = A;I wonder what is it for ... ?
3 comments:
One more power feature to be misused?
Not actually.
You may rename namespace if you have namespace with a very long name:
namespace verylongnameofthenamecpace
{
}
namespace A = verylongnameofthenamecpace;
or simplify usage of nested:
namespace A
{
namespace A
{
namespace A
{
}
}
}
namespace B = A::A::A;
Also some rare problems are faced here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1526.txt
As Ni@m mentioned, it's useful when dealing with namespaces with long names, or that are deeply nested.
You'll appreciate namespace aliasing when you spend some time with the boost libraries.
I've written a bit more about it's utility here: http://www.juicydata.com/CppNamespaceAlias.
Post a Comment