Reputation
5,150
Top tag
Next privilege 10,000 Rep.
Access moderator tools
Badges
8 25
Newest
 Good Answer
Impact
~155k people reached

1d
awarded  Good Answer
Aug
20
comment Checking array size in C/C++ to avoid segmentation faults
It's in fact common due to rounding, but you have to realize that such extra space (when present) is always uninitialized.
Aug
20
comment Checking array size in C/C++ to avoid segmentation faults
@lxrec: other way around. C/C++ does not/does have support for it respectively.
Jul
30
comment Design: Lisp (or other scripting language) as an interactive interface for C++?
The benefit of an existing language is that you don't need to write a book on how to use your language. Lua and Python are already well-documented.
Jul
29
comment How to handle design changes for auto_ptr deprecation in C++11?
As an aside, you may want to fold Foo::Initialize into Foo::Foo.
Jul
28
comment Is throwing new RuntimeExceptions in unreachable code a bad style?
On the other hand, many modern languages are complex enough. Turning every design pattern into a core language feature will bloat them even further. This is a good example of a design pattern which doesn't belong in the core language. As written, it's well understood not just by the compiler, but also by many other tools that have to parse code.
Jul
26
comment C++ to friend or not to friend
That's pretty theoretical. Perhaps the only common non-commutative case would be inline Vector operator*(double a, Vector v) { return -v*a; } and that still doesn't require friendship.
Jun
26
awarded  Nice Answer
Jun
24
comment How safe is it to compile a piece of source code from a random stranger?
C++ indeed limits the instantiation depth of templates to some implementation-dependent value. This used to be a few dozen; modern implementations have raised the limit to several hundred. Still, it's completely trivial to double the number of templates instantiations per level, so 100 levels would require the compiler to instantiate 2^100 templates. That's till just a DoS attack.
Jun
23
comment Would you create a specialized type just to wrap a primitive?
F# got the idea from C++. IIRC, Fermi Labs developed the SI units lib around 2002 or so. No performance impact of course, C++ has no abstraction penalty for such simple wrappers. And it correcly resolves that Length L; L==2; is invalid. 2 is a dimensionless number (meters^0), length is not (meters^1). That's a straightforward type error. Instead, use L==2_m (user-defined literals)
Jun
23
answered Avoid numeric errors in Naive Bayes method
Jun
14
comment Why do programs use call stacks, if nested function calls can be inlined?
@user2357112: Not all stack are call stacks. In particular, a call stack contains stack frames for every non-inlined funtion that's been called but hasn't returned yet.
Jun
13
comment Why do programs use call stacks, if nested function calls can be inlined?
@mastov: Why would recursion prevent inlining? Modern compilers actually do inline recursive calls.
Jun
13
comment Why do programs use call stacks, if nested function calls can be inlined?
@R.. : LTO is LINK time Optimization, not LOAD Time Optimization.
Jun
12
comment Why do programs use call stacks, if nested function calls can be inlined?
@Blrfl: Modern compilers actually don't need definitions in the header anymore; they can inline across Translation Units. This does require a decent linker, though. Definitions in header files are a workaround for dumb linkers.
Jun
9
answered Are “plus” and “minus” appropriate method names?
Jun
9
comment What is the “type” of data that pointers hold in the C language?
You're also permitted to take the difference between two pointers p1-p2. The result is a signed integral value. In particular, &(array[i])-&(array[j]) == i-j
Jun
9
comment What is the “type” of data that pointers hold in the C language?
Indeed. The best known counterexample is the Intel 8086, where pointers are two integers.
May
28
comment How do I model this Shipping Routes scenario?
@SolilquyOfChaos: Please note, that's a Graph class intended for Dependency Graphs. Dependency Graphs have an important property : they're never cyclic. And your graph definitely is cyclic.
May
28
comment How do I model this Shipping Routes scenario?
@SolilquyOfChaos: The graph is small enough that you don't absolutely need it. At that point you're almost answering the questions by hand. But the intent of this question really is to make the small graph and solve the 5 problems on that graph.