vendredi 19 décembre 2014

Are there any gotchas or limitations when template aliasing shared_ptr and unique_ptr?

For the simple reason of cutting down on typing something like:



std::shared_ptr<...>;
std::unique_ptr<...>;


every time I want to use smart pointers, I thought about using template aliases:



template <typename T> using sptr = std::shared_ptr<T>;
template <typename T> using uptr = std::unique_ptr<T>;


So I could use them like:



sptr<...>;
uptr<...>;


Assuming I guard them in my own namespace, are there any gotchas or limitations in using a template alias with shared/unique_ptr this way? Will I ever be unable to do something I can do with the direct template syntax that I can't with the alias? Is this a bad idea for other reasons?


Aucun commentaire:

Enregistrer un commentaire