News for hackers. Stuff that matters.
Re:Mapping Strings in C++ by janoc on Wednesday April 12, 2017 @06:45PM (#14102438)
Good luck chasing bugs then, though. qsort() will be totally happy comparing apples to oranges - aka there is zero type safety.

Templates give you compile time type checking, that's why one doesn't pass void pointers like this anymore but uses templates to implement generic functions.

Re:Mapping Strings in C++ by pg314 on Thursday April 13, 2017 @05:33AM (#14105419)
> Good luck chasing bugs then, though. qsort() will be totally happy comparing apples to oranges - aka there is zero type safety.

That's a fair point. However, I do not tend to make many of the mistakes that would be caught by the C++ type system. But different people tend to make different kinds of mistakes.

The type bugs that happen tend to be pretty obvious and easy to debug. Good luck to you debugging template code :) I've had a harder time debugging C++ code than C code. Again, YMMV.

Re:Mapping Strings in C++ by koja86 on Thursday April 13, 2017 @12:30PM (#14108474)
I agree that YMMV.

Although sometimes "I do not tend to make many of the mistakes that would be caught by the C++ type system" might be related to "how to use C++ type system so it would catch mistakes people tend to make".