Im trying to write a scoped pointer class which calls delete once it is destroyed. I realized that i would need to check whether my pointer is pointing to an array or not, so i could call the right delete. Taking inspiration from std::unique_ptr i used type_traits to check if the template argument, which holds the type pointer, is an array or not:
template <typename type, bool _Dx = std::is_array<type>::value>
class scoped_ptr {
private:
type* m_ptr;
//...
};
template <typename type>
class scoped_ptr<type, true> {};
But if my template argument type is "int[]" the codes invalidates because i cant have an "int[]* m_ptr" How can i solve this problem? How can i pass int[] argument and have "int* m_ptr"