Quantcast
Channel: Linux Programming Blog
Viewing all articles
Browse latest Browse all 10

C++ exception specifications are evil

$
0
0

When I began to program in C++ I was already experienced in C and had written some code in Java. After writing few thousands lines of code in this language I felt comfortable with all of it's goodies like templates, inheritance, operator overloading and (I thought so) exceptions. But I made at least one mistake: I used exception specifications. My intention was to use them as in Java: tell the compiler that this method throws specific exceptions so it can use this information to optimize code and tell me when I'm throwing/catching wrong exceptions. A great surprise was that in practice in most cases writing exception specifications slows the code and introduces bugs!

read more


Viewing all articles
Browse latest Browse all 10

Trending Articles