Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!


Forgot your password?

Slashdot videos: Now with more Slashdot!

  • View

  • Discuss

  • Share

We've improved Slashdot's video section; now you can view our video interviews, product close-ups and site visits with all the usual Slashdot options to comment, share, etc. No more walled garden! It's a work in progress -- we hope you'll check it out (Learn more about the recent updates).


Comment: Re:Problems in C++ (Score 1) 386

by Jamu (#48861387) Attached to: Is D an Underrated Programming Language?

Dude, don't use square brackets with STL arrays and vectors, just to make your code more readable. The [] operator skips bounds checking, which is the main reason for using these classes in the first place. At() is the proper methodology to use in pretty much every case, unless you are so confident in your bounds that its worth the trivial speed increase in access time.

Bjarne Stroustrup's solution:

class Vec : public std::vector<T>; {
using vector<T>::vector

T& operator[](int i)
{ return vector<T>::at(i); }

const T& operator[](int i) const
{ return vector<T>::at(i); }

Page 97 of The C++ Programming Language.

Porsche: there simply is no substitute. -- Risky Business