|
|
|
|
|
by matthavener
4842 days ago
|
|
I didn't quite "get" the point of the pointer/copy option on interfaces, but this makes it crystal clear. This works around such a common problem in writing C++ templates (which is really the only equivalent polymorphism if you want to dispatch a function on a native type): template <class T> void doSomething(const T &expensiveCopy);
Versus: template <class T> void doSomething(T cheapCopy);
As usual, boost provides another crazy template hack to work around this issue:http://boost.sourceforge.net/libs/utility/call_traits.htm |
|