Mutable and volatile

September 16th, 2009 § 2 Comments

I am a little busy nowadays, so excuse me for posting yet another somehow basic article. However, I still retain the hope that some of you are not familiar enough with at least one of these two keywords in C++.

« Read the rest of this entry »

Substitution failure is not an error, part II

September 12th, 2009 § 2 Comments

As promised, this article continues and provides a thorough explanation of the previous post.

« Read the rest of this entry »

Substitution failure is not an error, part I

September 11th, 2009 § 6 Comments

Explanation on what is SFINAE can be found at wikipedia. I’ve tried to write my own explanation but ended up with the conclusion that it’s best described there, and I wouldn’t want to copy&paste stuff. If you have any question marks floating around your heads, please don’t hesitate to ask.

SFINAE is used a lot in meta-programming. For example, you will be able to find many constructs in boost that are making use of this idea.

I’ve come across a pretty nice and complex use of SFINAE on stackoverflow the other day. The code below generates a templated class HasX, whose member HasX::value denotes whether the class T has a member (data or function) called x, or not. Let me introduce the code, and an explanation will follow.

« Read the rest of this entry »

Trigraphs

September 8th, 2009 § 7 Comments

How would you like the next piece of code?

??=include <iostream>
??=define A "hey"

int main () ??<
    char x??(??) = A;
    if (0 ??' 1)
        std::cout << x << std::endl;
    // what do you say about this code??/
    std::cout << "amusing" << std::endl;
??>

« Read the rest of this entry »

More on arrays

September 6th, 2009 § 2 Comments

Let’s have a better look at native arrays.

« Read the rest of this entry »

Where Am I?

You are currently viewing the archives for September, 2009 at 0x.