Last post on this topic, since I'm not sure this is going anywhere:
standard vectors just poses pointers. Right? Nothing further and they do not mess with a template stuff.
std::vector _is_ a template. That's why you use it like:
std::vector<int> foo;
The `<int>` bit is a clear sign that you're instantiating the `std::vector` class template over the `int` type parameter.
It realy does not, and if it does..... nope, c++ cannot turn to a hell of a brain language can it?
I'm not entirely sure I'm comprehending your objection, here.
The compiler works in various stages. After preprocessing, there's lexing, parsing, semantic analysis, IR generation, high-level optimization, IR lowering, low-level options, and finally actual machine code generation. Most of the work of verifying templates and instantiating them happen entirely in the earlier stages, though C++ requires some "fuzzines" between the classic stages due to some of its semantic oddities.
You can totally write templates that are constrained today using meta-programming techniques, particular SFINAE. Consider:
template <typename T>
auto lerp(float a, T lhs, T rhs) -> decltype(a * lhs + (1 - a) * rhs)
{
return a * lhs + (1 - a) * rhs;
}
That function will thanks to SFINAE refuse to even instantiate for a type T that does not support operator +. If you try to call lerp on something like a pointer, you'll get a compiler error up front telling you that such operations are not supported. Trying to call it with T=void* for instance, Clang says:
10 : error: no matching function for call to 'lerp'
void* c = lerp(1.0f, a, b);
^~~~
2 : note: candidate template ignored: substitution failure [with T = void *]: invalid operands to binary expression ('float' and 'void *')
auto lerp(float a, T lhs, T rhs) -> decltype(a * lhs + (1 - a) * rhs)
^ ~
1 error generated.
Boost has a library library for Concept Checking that generalizes this support.
You can use std::enable_if, std::is_integral, and various other facilities and type traits (all templates!) instead of or in addition to decltype.
Once the Concepts TS is out (around C++17) you can also write the much simpler:
template <Arithmetic T>
T lerp(float a, T lhs, T rhs)
{
return a * lhs + (1 - a) * rhs;
}
Note the `Arithmetic` which is a constraint, meaning that `T` must conform to the given constraint and not just be any generic type.