Hacker News new | past | comments | ask | show | jobs | submit login

errr, no.

It is in no way more generic or less error prone. Just asserting that does not make it so.

You _can_ get the loop wrong, if you accumulate(dice1.begin(), dice2.end(), ...) for example, or switching the begin() and the end(). You can just as easily change the addition operation to anything else in the non-boost/stl version.

In the 2nd version, when you _do_ make a mistake, if the compiler catches at you get an error message that's totally unreadable with 2000 character error lines. And if the compiler doesn't catch it, and it causes a runtime problem, it is also extremely awkward to backtrace.

Not to mention, you need the latest-and-greatest compiler to do the lambda thingy, for no obvious benefit.




Most STL implementations catch the two errors you gave in debug mode (switching begin and end, using two different containers, etc.), and many more!

As for the compiler giving crazy errors, it's true for g++ mainly. VC10 and most of all clang give intelligible messages.


I haven't been following STL implementations recently, but that definitely wasn't the situation even in 2007 (Over 10 years after STL was finalized..); In fact, the only implementation that it did back then was STLPort, at a huge performance hit, and only at runtime.

And what you say about compilers is EXACTLY why I wrote the "latest and greatest". It's only recent clangs that can give intelligible messages for C++ (if at all) because Clang C++ support is not even ready for production yet.

VC++ 2005 (last I used) did not get give reasonable errors.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: