0
基於type_traits信息是否有可能產生函數/類模板過載?C + +有基於type_traits有模板重載的方法嗎?
例子:
#include <type_traits>
template<typename Object>
class object_worker
{
public:
object_worker(Object&& o) // o - is not POD
{
// do something
}
};
template<typename Object>
class object_worker<std::is_pod<Object>::value == true> // how to make this thing work?
{
public:
object_worker(Object &&o) // o - is POD
{
// do something different
}
};
- 是否有做一些有一定技術?像部分模板專業化
- 如果可以實現這一點,它的名字是什麼? (例如模板偏特,概念)
保存我的一天!它不應該被稱爲_full specialization_ for第二個模板參數嗎?我想,_partial_就是這樣的:'template class cls {};' –
andrgolubev
只希望沒有人實例化'foo x;':-) –
@KerrekSB Aye,通常最好是圍繞這個也許將它作爲* detail *基類。 – DeiDei