On 6/11/2015 12:39 PM, Joe wrote:
> I'd like to know if it's possible to initialize a class w/o passing in a
> type to the template,
No. Templates are *instantiated* when their *arguments* have specific
values. If the argument is a type, it needs to be specified in order to
instantiate the template.
> just use the base class since I don't need any of
> the template members.
By definition, you do. You're free to rewrite your program in such a
way that it doesn't have a template, and instead has a class which you
then use. But a class template *needs* its argument to become a class.
> I thought I read that passing in null pointers was
> ok, but didn't quite understand the const expression part of it.
Huh?
>
> template <class MyType>
> class MyClass
> {
> private:
> std::shared_ptr<MyType> tvar; // <---- don't need to use
>
> public:
> MyClass() { } // <--------- use this ctor
> MyClass(std::shared_ptr<MyType> myT) : tvar(myT) { }
> };
>
> So to create a simple object of MyClass, I tried something like this.
>
> std::unique_ptr<MyType<nullptr>> mt;
> mt = std::unique_ptr<MyType<nullptr>> { new MyClass(); };
>
This is wrong on several levels. Perhaps you could start over by
explaining what exactly you're trying to accomplish.
V
--
I do not respond to top-posted replies, please don't ask