Whats better? typedef or using
I was wondering what is the better of the two type alias
using name = type or
typedef type name.
Like are there advantages in any?
They are actually the same. I prefer first one for more intuitive behavior when working with function pointers and consistency with other code. Second one is just C compatibility.
The functionality provided by an an alias declaration is a superset of that provided by a typedef.
template < typename T >
using my_vector = std::vector< T, my_pool_allocator<T> > ;
An alias declaration may result more easily understandable syntax (to those who have just started learning C++).
Other than that, there is no difference between the two.
typedef int function_type( int, int ) ;
using function_type = int( int, int ) ;
function_type* pfn = nullptr ;
Thank you guys, so I should use the using, because its C++11
Topic archived. No new replies allowed.