How can I provide template specializations for typedefs of the same type?

后端 未结 4 544
长情又很酷
长情又很酷 2021-01-20 02:49

A 3rd party SDK defines several typedefs, e.g.:

typedef unsigned char SDK_BYTE
typedef double SDK_DOUBLE
typedef unsigned char SDK_BOOLEAN

4条回答
  •  清酒与你
    2021-01-20 03:16

    I believe this can be done with an unused template argument and an unused-but-unique struct declaration as the argument:

    template
    class variant_cast { /*...*/ };
    
    template<>
    SDK_BYTE variant_cast::operator()/*...*/
    
    template<>
    SDK_BOOLEAN variant_cast::operator()/*...*/
    

提交回复
热议问题