482 karma · joined July 15, 2013
for (e : c)
which would be equivalent to: for (auto &&e : c)
Gcc implements this when compiling with -std=c++1z. My understanding is that it was rejected by the committee.[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n385...
[2] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n399...
If you are looking for low memory overhead ordered sets/maps, then B-Trees can provide that.
It's also worth pointing out the style of loop they give can't be used at all if you are counting down iterators or pointers instead of numbers.
std::size_t i = foo.size();
while (i != 0) {
--i;
...
}But ya, B-Trees will (sometimes significantly) outperform BSTs for small keys because they will have fewer cache misses. Also interesting is that the idea that RB-Trees are faster than AVL trees for insert/delete may be outdated as well. I've seen benchmarks of AVL trees beating std::set in both libstdc++ and libc++ for both of those operations. Again this is probably due to less cache misses.
My B-Tree story is actually a B+Tree story. B-Trees (and B+Trees) can can actually be used for more than just ordered sets/maps, I've implemented a C++ sequence container[1] that allows O(log n) random access insertion and deletion. It is _much_ faster than a similar container[2] implemented using AVL trees, but at the cost of iterator stability.
A race condition or race hazard is the behavior of an
electronic, software or other system where the output is
dependent on the sequence or timing of other
uncontrollable events.
Example: https://gist.github.com/anonymous/eb72f1091bd1592df552Output:
$ for i in {0..10000}; do ./race; done | sort | uniq
0
1 let foo: u32 = "3".parse().unwrap();
and C#'s is written: var foo = uint.Parse("3");
Both require familiarity with the stdlib (Parse throws, TryParse doesn't, unwrap fails).I agree that TryParse is worse than Rust's ADT approach, but that's a different issue, much like nullable references. The author is asserting that results are superior to exceptions and I am asserting that no, that is just a bad application of exceptions. Additionally, I am asserting that without exceptions, you limit what programmers are willing to propagate through their interfaces because errors become viral.
How is Parse any less explicit than unwrap ?
Complaining about the existence of Parse is like complaining about the existence of unwrap in Rust.
C++ (another systems language) is probably a better comparison for out of memory.