-1
在LLVM代碼,我發現這個代碼示例:兩種類型的模板裏面(?字)在C++
template <typename TagT, typename... MemberTs> class PointerSumType {
uintptr_t Value;
typedef detail::PointerSumTypeHelper<TagT, MemberTs...> HelperT;
public:
PointerSumType() : Value(0) {}
/// A typed constructor for a specific tagged member of the sum type.
template <TagT N>
static PointerSumType
create(typename HelperT::template Lookup<N>::PointerT Pointer) {
PointerSumType Result;
void *V = HelperT::template Lookup<N>::TraitsT::getAsVoidPointer(Pointer);
assert((reinterpret_cast<uintptr_t>(V) & HelperT::TagMask) == 0 &&
"Pointer is insufficiently aligned to store the discriminant!");
Result.Value = reinterpret_cast<uintptr_t>(V) | N;
return Result;
}
TagT getTag() const { return static_cast<TagT>(Value & HelperT::TagMask); }
template <TagT N> bool is() const { return N == getTag(); }
//.....
};
我的問題是:什麼意思template <TagT N>
,怎麼可能有內部的兩個詞模板?
謝謝,如果你花時間回答我。
P.S.你可以在http://llvm.org/docs/doxygen/html/PointerSumType_8h_source.html
'template'也是兩個單詞。怎麼可能沒有兩個字? –
melpomene
它是__非模板參數___ – Danh