简体   繁体   中英

How to specialize a class template for vector?

I am a bit confused about the syntax for template parameters... How do i specalize this template:

template <typename T> class MyTemplate{
    public: 
        void doSomething(T){}
};

for std::vectors, ie I would to write something like

template <std::vector<typename T> > class MyTemplate{
    public:
        void doSomethingElse(std::vector<T>){}
};

to make the class behave differently, depending on whether the template parameter is just any type T or a vector.

Like this:

template <typename T>
class MyTemplate<std::vector<T> > {
    ...
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM