News for hackers. Stuff that matters.
Re:The C++ Programming Language (4th Edition) by gordaco on Wednesday May 15, 2013 @05:21AM (#5710934)
They require you to write the function for use with templates; as long as the callee is ready to use templates, you can pass anything that fits the interface needed. Everything is done at compile time.

You can use a generic type as argument (template <typename T> void method(T arg) ), or a templated one (template <typename T> void method(MyObject<T> arg) ). In both cases the method will fail to compile if the body requires a missing field or method, but in the second one you get a standard "type mismatch" error, while in the first you'll get a "type X doesn't support method Y".

There are no comments on this comment yet.