0
如何從構造函數推斷模板參數?如何從構造函數推斷模板參數?
template<class $sign, signed $size>
class Integer;
template<>
class Integer<signed, 8>
{
public:
typedef signed long long type;
};
typedef Integer<signed, 8>::type Int64;
template<class $sign, signed $size>
class Integer
{
public:
Integer(Integer<$sign, $size>::type a){}
// 1LL(Int64) => Integer<$sign, $size>::type => $sign, $size
//How to infer <$ sign, $ size>
};
int main() {
Integer a(1LL);
return 0;
}
如何從構造函數推斷模板參數?
1LL(Int64的)=>Integer<$sign, $size>::type
=> $符號,$大小
如何推斷<$ sign, $ size>
舉一個例子 謝謝 –
@呂詩銘更新我的回答 – Curious
非常感謝你 –