C++ criticized/defensed (cont'd)
ajoo 2002-06-11 11:33:31 reached the 30 posts limit. So we can talk here.
huwx:
compared to gj, template is more like macro. It is just an advanced macro.
generics have nothing to do with single inheritance. no relationship, no contradiction.
What generics is for? type safety. That's it. template has meta-programming, but gj does not. template has code-bloating, gj does not.
copy&paste my question here again for discussion:
give an example of sizeof:
I had a discussion with a C++ guy on mit bbs.
I would say his C++ knowledge is well beyond average level. He knows pretty much about meta-programming.
He raised a question for one problem:
need to implement a template based class, in which we need the following method
void add(T val);
What he's puzzled is that he does not know what the T is and he wanted his code as efficient as possible.
He's concerned about the overhead of copying in pass-by-value,
While, he's not too happy about the extra address indirection of pass-by-ref either.
So, he's got a plot.
Define a size limit, for type T that sizeof(T)>limit, use const T& for the add method.
for other types, use T for the add method.
How do you guys think about his design? Is it scalable? Is it cross-platform? Should he forget about "programming"?