I want to create an alias template for std::unique_ptrthat supplies my own deleter function.
unique_ptr has both a scalar and an array implementation, they are defined as follows:
template <class T, class D = default_delete<T>>
class unique_ptr
template <class T, class D>
class unique_ptr<T[], D>
I'm having trouble trying to override both scalar and massive versions unique_ptr. It is easy to make an alias for only one version, for example:
template<class T>
struct Deleter {
void operator()(T* ptr) { delete ptr; }
};
template<class T>
using my_unique_ptr = std::unique_ptr<T Deleter<T>>;
But when I try to add a second alias, for example:
template<class T>
struct ArrayDeleter {
void operator()(T* ptr) { delete [] ptr; }
};
template<class T>
using my_unique_ptr = std::unique_ptr<T[], ArrayDeleter<T>>;
... I end up with compiler errors because " my_unique_ptr" is ambiguous.
My question is: How do I create one alias that works for both an array and scalar versions unique_ptr?