Is There Anything Like a Templatized Case-Statement

后端 未结 5 963
没有蜡笔的小新
没有蜡笔的小新 2020-12-16 18:18

So I have this really ugly code:

template 
std::conditional_t

        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 18:28

    Something like this perhaps:

    template  struct SuitablySized;
    
    template<> struct SuitablySized {
      typedef char type;
    };
    template<> struct SuitablySized {
      typedef short type;
    };
    // Add more cases to taste
    
    template 
    typename SuitablySized::type foo(T bar);
    

提交回复
热议问题