简体   繁体   中英

c++ templating to specific type without using traditional Template Specialization

template <typename T_>
class my_class {
public:
       typedef T_   value_type;
       typedef T_ * pointer;

I'm developing a templated class, however because the C++ error detection and intellisence suck for templated stuff, is there a way I can set the template to example int to get the benefit of intellisence, and then when I'm done development just switch it back and fix a couple errors?

I still want my code to be generic and re-writing it as Template Specialization is too much work.

I want to be able to do something like

template <typename T_ = int>
class my_class {
public:
       typedef T_   value_type;
       typedef T_ * pointer;

I'm not completely sure I understand what you're trying to accomplish, but you could typedef T_ to int in the class and disable the template statement, either through the pre-processor or commenting it out.

#ifndef NO_MY_CLASS_TEMPLATE
template <typename T_ = int>
#endif
class my_class {
#ifdef NO_MY_CLASS_TEMPLATE
       typedef int T_;
#endif
public:
       typedef T_   value_type;
       typedef T_ * pointer;

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