I'm having a problem with a template class I'm writing. I suspect that what I want to do is impossible, but I just wanted to throw it out there and see if I'm just missing something.
I'm writing a template that is effectively a container, and I need to be able to construct them from like containers with compatible (static_cast-able) data types.
Something very much like this:
In the case where t and t2 are the same data type, I would think that this would generate the copy constructor. My testing shows that it doesn't, and I have to explicitly write the copy constructor.Code:export template <typename t> class Wrapper { t WrappedObject; public: Wrapper(); template <typename t2> Wrapper(const Wrapper<t2> ©); };
I strongly suspect that it isn't possible to generate a copy constructor by this method. Can someone show me a way to do it, or is it just plain impossible?