You should be able to use namespace aliases for the class:
using B = A::B;
However you can't do that with the member function, not even with static member functions.
Edit: According to this SO answer (What is the difference between 'typedef' and 'using' in C++11) this should be valid, and actually creates a type alias in the same way that typedef
does. However, it's C++11 only.
There is a workaround for static member functions in C++11, by declaring a variable pointing to the static function:
struct Foo
{
static void bar()
{ }
};
auto bar = Foo::bar;
Edit: Of course, having a global variable pointing to a static member function is possible in the older C++ standard as well, but it's more messy than using the auto
keyword of C++11. In the example above it would be:
void (*bar)() = Foo::bar;
A::f()
. – Nd