I'd like to make a typedef for std::list<std::unique_ptr<>>, so I could type PtrList<A> and it would be replaced by std::list<std::unique_ptr<A>>.
I know the way to do that with #define:
#define PtrList(x) std::list<std::unique_ptr<x>>
But I think typedef would be proper. However I don't know how to realize that. Could someone tell me how to typedef this ?
First, try not to use #define to generate code. Except for conditional compilation, #define should be avoided.
A correct type alias:
template<class T> using PtrList = std::list<std::unique_ptr<T>>;
Example use:
PtrList<int> intPtrList;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With