Skip to content

{ Category Archives } C++

Fun with C++: new, delete and Some of the Rest of the Story

Every C++ programmer knows new and delete and how they work. At least it must be so. I sure as hell didn’t know all the theory and detail behind C++ memory management facilities until 3-4 years ago, and I’m obviously still learning the practical details. So, please bear with me and see if there are [...]

Time, Only Time

I have a post about measuring time in a game engine on the Grashasp Dev Blog. Give it a read if you have the time and you are interested.

Fun with C++: Function Try Blocks

C++ is complex. That might sound like an about right to two groups of people – those who don’t know C++ and those who really know C++ – but only those who really know understand the depth of that statement. I’m only beginning to learn C++ and I’m only just learning the depth of it.

Take [...]

Fun with C++: Singletons

I just realized that I’ve not posted anything technical in a long while. Here’s my effort to remedy the situation.
This is a modified version of the straightforward implementation of the “singleton” pattern (STFW yourself.)
Let me add this. I’m rather proud of this code, so I ask you please to give this code a read if [...]

Of Boost and Men

Boost is a great collection of libraries. The functionality is so diverse and the quality is so high and the design is so careful that it’s almost part of the standard C++ library (of course, many of Boost’s sub-libraries has already been accepted for inclusion into the next version of C++ standard library with little [...]

Boost 1.36.0 is Out

Shame on me! Boost 1.36.0 got released and I didn’t even know it was coming this soon. It’s been several weeks that I haven’t read the mailing list. Think of all the C++ goodness I’ve lost!
I’ll get it off the SVN (if my ISP let’s me; damned idiots) and build it in a few hours, [...]

Fun with C++: Useless Consts?

Many C++ programmers see the keyword “const” as something redundant that only gets in the way. They curse Stroustrup and his ancestors each time they encounter a const-related compile error because of that view and fail to use it correctly quite often (note that I’m not saying that I’m not one of these people, but [...]

Fun with C++: When Parentheses Don’t Call!

Just a quick one. Most of us have come to think of parentheses as sometimes necessary but always harmless little creatures. Our view is that unless parentheses change the order of evaluation (and therefore the meaning) of an expression, they are completely harmless.
Well, while that is true almost by definition, there are cases that we [...]

C++ “Glasses”!

The Slashdotters put together a list of questions for Bjarne Sroustrup to answer a while back. The Q&A is interesting on its own, but this comment by an anonymous coward (as they are called on /.) is the funniest piece of writing I’ve read in a long time!
Read the Q&A and the rest of the [...]

Fun with C++: Metaprogramming, Part 1

Metaprogramming can mean many things, but all of them can be made to (loosely) fit under the description of “writing programs that write or rather describe (a class of) other programs.” A classic and somewhat useless sample of this is writing a program that prints it’s own source code. My first real contact with this [...]

Fun with C++: Macro Pitfalls, Batch 1!

(UPDATE: Added the 6th item.)
I’m a fan of C/C++ preprocessor macros. I would be very happy if C++ received macros on par in power with those of Common Lisp macros, but that’s only a dream! We have to work with what we have.
Anyways, with use of macros come a lot of potential pitfalls. I’m going [...]

Unguaranteed Order of Pre-main Object Initialization in C++ – Any Solutions?

The C++ standard leaves the relative initialization order of global and static data undefined. The only thing that the compilers must guarantee is that all such data have been initialized before the invocation of main(). In any large and well-designed project, there are no or very few global objects. But static member data in classes [...]

C++: Fun With Precompiled Headers

Those of you who have worked on middle-sized to large projects in C++ (any more than 50000 lines of code) know that build time becomes a rather important factor in the development process. On any typical project, a full build time can very well exceed 10 minutes on a modern machine. Although there are many [...]