You need to be able to mangle template arguments
template <std::string temp>
void f() {
// ...
}
f<"foo">();
f<"foo">(); // same function?
Now an impl would need to come up with a unique sequence of characters for a std::string
or, for that matter, any other arbitrary user defined class, storing a particular value, the meaning of which is not known to the implementation. And in addition, the value of arbitrary class objects can't be calculated at compile time.
It's planned to consider allowing literal class types as template parameter types for post-C++0x (see below), which are initialized by constant expressions. Those could be mangled by having the data members recursively mangled according to their values (for base classes, for example we can apply depth-first, left-to-right traversal). But it's definitely not going to work for arbitrary classes.
As of C++20, we are now allowed to use structural class types as template parameters. In a nutshell, structural classes must have a constexpr
constructor, destructor and only structural-type members and base classes (like scalars, arrays thereof or references). They must also only have public and non-mutable
base classes and members. These provisions, if the template is instantiated with a constant expression converted to the parameter type, allow the compiler to mangle the argument meaningfully.