It’s best to think of it as a bunch of functions, which is actually the case. Consider a class Typethat here represents the internal representation of a type compiler.
template<typename T> class X {
T t;
};
At runtime, C ++ you can express it as
Type* X(Type *t) {
static std::unordered_map<Type*, Type*> cache;
if (cache.find(t) != cache.end())
return cache[t];
Type* ret = new Type;
ret->DataMembers.insert("t", t);
return cache[t] = ret;
}
Of course, specializations and the like will require a little more. Using this model, however, is easy for two things.
A) Creating an instance of a template is equivalent to calling a function that happens at compile time, just like constexpr. Of course, a smart compiler can do something else as an optimization, but in the general case.
B) How it applies to any other functions provided by the templates.
Turing, - . , , , - , . , EDSL .