Tag Archives: operators

Binary Operator Overloading

In C++, there are two forms of binary operator overloading you can use when designing an API. The first form is to overload the operator as a member function of the class, and the second form is to overload the … Continue reading

Posted in C/C++, Framework Design | Tagged , | 2 Comments

Theory and Reality

One thing which I am pretty religious about is the placement of ++ and — in an expression. You have two options for where it can go. If it goes before the operand, it’s a pre-increment/decrement. If it goes after … Continue reading

Posted in C/C++ | Tagged , | Leave a comment

Preventing Evil Operator Overloading

While doing some research on allocators, I noticed that the language specification has some interesting wording with regards to getting the address of an element from an allocator. Specifically, it says (Section 20.6.9.1 Clauses 2 & 3): Returns: The actual … Continue reading

Posted in C/C++ | Tagged | Leave a comment

The Placement New Operator

I’d like to shed a little bit of light on a dusty corner of the C++ language: there’s more than one “new” operator! Well, since you’ve likely encountered the vector new (new[]) operator, I should say there’s more than two … Continue reading

Posted in C/C++ | Tagged , , | 13 Comments

The comma

As C and C++ programmers, we’ve probably seen and used the comma countless times in our applications, without thinking too much about it. However, there are some very interesting points to this piece of punctuation that are worth discussing. The … Continue reading

Posted in C/C++ | Tagged , | 4 Comments