Anyway, @sbi, one kilogram cannot weigh 1 Kg (kelvingram or how-to-call-it), and it looks like quite abstract unit, with no sane physical interpretation.
then I would just take the iterator advancement out of the for loop condition and make it an infinite loop that breaks out when it runs out, and checks after every increment
for (auto i = x.begin(), e = x.end(); i != e; ) { auto firstthing = *i++; if (i == e) { error = true; break;} auto secondthing = *i++; ...you have your pair... }
@DeadMG Maybe. I just looks Psalm 119 up and it read "Blessed are the undefiled in the way, who walk in the law of the Lord" so I could not resist s/l/n/ and s/Lord/Standard/ felt appropriate too.
don't "think" things like that. It is possible for a container implementation to do front() better.
but they both work yes
front() says almost directly, "gimme a reference to the first thing". begin() means set up an iterator because I might go iterating through it. then take that return value and dereference the iterator into a reference. It's obvious that front() is better
This question attempts to collect the few pearls among the dozens of bad C++ books that are released every year.
Unlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a good C++ book...
There seems to be no point in forbidding this shortcut, and (all?) other languages with similar concepts of nested name spaces allow it
And they didn’t leave namespace syntax untouched in C++11, they added the inline namespace feature whose importance eludes me at the moment, to be honest
yes, one of the things I think is a downside of C++ is all the places where you say "oh just type out 16 lines of code that look similar to the last 30 times you did it" to do common things like that
@ThePhD you could "pull in" the operator= (with using) and make wrapper constructors that forward everything. but that's the point, why not automate it with typedef'd template.
you would actually use it to provide different default parameters (for example) like my FastVector example
a more meaningful example would be if you made a special allocator that allocates memory in DMA-capable memory, and you wanted to make a DMAVector that allocates memory appropriately
@R.MartinhoFernandes Brilliant. So much explained... Yesterdays paper here, on the other hand, showed some more shockingly real statistics: 926 deaths by firearms in the US since "Newton". (Quoting from memory: 64 kids...)