If you need to do this often, then I think you could create
template<typename T> struct container { typedef T& reference; typedef const T& const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef T value_type; typedef T* pointer; typedef const T* const_pointer; };
And inherit from it. In the standard library, std::allocator defines all of these typedefs, so inheriting from it will technically do what you wanted, and should not impose any overhead at runtime. I still think it's best to just write your own typedefs.
source share