What’s the relationship between C++ template and duck typing?

To me C++ templates are a compile-time version of duck typing.
The compiler will compile e.g. Class and as long as your Duck
has all needed types it will instantiate a class.

If something is not correct(e.g. copy constructor missing) the compilation fails.
The counterpart in real ducktyping is a failure when you call a function with a
non-duck type. And here it would occur at runtime.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)