#include #include #include template class arrayview { public: arrayview(std::size_t size) : m_size(size) { std::cout << "Called single argument ctor with size " << size << std::endl; if(!size) { return ; } m_buffer.reset(new T[size]); } arrayview(std::complex other) : arrayview(2) { std::cout << "Called std::complex ctor" << std::endl; this->complex() = other; } std::complex& complex() { return *reinterpret_cast*>(m_buffer.get()); } private: std::unique_ptr m_buffer{nullptr}; std::size_t m_size{0u}; }; int main() { std::cout << "Calling the arrayview(5):\n"; arrayview view{5}; std::cout << "\n Calling the arrayview(5):\n"; arrayview flview{5}; return 0; }