I often find myself doing something like
some::name::space::Foo<Bar> test;
some::name::space::Foo<Bar>::SomeTypedef stuff = test.hi();
Now obviously I dont want to retype the type... In this specific case I could just use 'auto' but this is just an example (maybe I need the type to pass it as a template parameter to a vector or whatever).
Id like to do
some::name::space::Foo<Bar> test;
test::SomeTypedef stuff = test.hi();
But thats ILLEGAL
Is typedef the only way to do this in C++ (apart from duplication)? (Its fine for many uses of the type, but if I use the type like twice, writing out the typedef just feels like it takes even more work)
EDIT:
This would save at least a few keystrokes and eliminate the need to move stuff around, yay! But its only worth it if theres multiple places where the behavior is needed because ill need to #include the header with the macro T_T
#define WITH_ALIAS(type, alias) typedef type alias; type
//Rarely do macros, dont know if that even works xD EDIT2: seems to...
WITH_ALIAS(some::name::space::Foo<Bar>, fubar) test;
test::SomeTypedef stuff = test.hi();