Tag dispatch versus static methods on partially specialised classes

后端 未结 4 1284
無奈伤痛
無奈伤痛 2020-12-07 08:54

Suppose I want to write a generic function void f(), which does one thing if T is a POD type and another thing if T is non-PO

4条回答
  •  抹茶落季
    2020-12-07 09:31

    I know this is an old question with the answer already accepted, but this might be a viable alternative:

    template
    std::enable_if_t::value> f(T pod)
    {
    }
    
    template
    std::enable_if_t::value> f(T non_pod)
    {
    }
    

提交回复
热议问题