C++ template specialization without default function

后端 未结 5 1636
轻奢々
轻奢々 2021-02-01 02:49

I have the following code that compiles and works well:

template
T GetGlobal(const char *name);

template<>
int GetGlobal(cons         


        
5条回答
  •  梦谈多话
    2021-02-01 03:06

    I would suggest not to actually provide an implementation, just a bare declaration of the method.

    The other option would be to use a compile-time assert. Boost has a number of such beasts.

    namespace mpl = boost::mpl;
    BOOST_MPL_ASSERT((mpl::or_< boost::same_type,
                                boost::same_type >));
    

    There is also its message version counterpart, which would help.

提交回复
热议问题