News for hackers. Stuff that matters.

johnny531

Re:Has C++ jumped the shark? on Monday March 28, 2011 @04:21PM (#2379907)
Try stripping debug symbols. As to compile time, the pimpl pattern is your friend here.
Re:Has C++ jumped the shark? on Monday March 28, 2011 @04:18PM (#2379890)
Huh? Templates in C++ are pay-for-what-you-use; only those instantiations required by your code are generated.

Note also the ability to extern templates added in C++0x, which allow you to collapse common instantiations to a single object file.

Re:Real cost of C++ exception vs error-code checking on Tuesday March 08, 2011 @10:04PM (#2303612)
Not sure what you mean with copy ctor bloat, but for your_flavor_of_smart_ptr, that's what the typedef keyword is for.

A common idiom I use is to typedef a class's preferred smart-pointer as ptr_t within the class namespace. Passing them around now looks like:

void some_function(my_class::ptr_t);

Exception safe, clear semantics, & no bloat.

Re:Real cost of C++ exception vs error-code checking on Tuesday March 08, 2011 @09:53PM (#2303589)
Really? C++ is perhaps the slowest moving language in my repertoire in terms of 'popular' approaches to solving common problems. Look how long a c++0x specification has taken.

And also, www.boost.org. Don't code c++ without it.

Re:Real cost of C++ exception vs error-code checking on Tuesday March 08, 2011 @09:48PM (#2303578)
If only c++ had some sort of static type system which could be leveraged to provide compile-time checks...

But seriously, this is a large part of the power of c++'s type system. Taking the article's example, if the argument types were of (user class) 'non_zero_float', there's no possibility for error.

You still have to check that your input is non-zero at some point, but you've now focused it into one place (the 'non_zero_float' class ctor), and other chunks of your program depending on those type semantics no longer need to worry about it.