whatIsThisFor

Check out this C++ code fragment at the beginning of the MessageBase class template definition:

After staring at it for a few minutes, I was able to distill the essence of the idiom(???) used in the code as:

I can’t figure out why B was designed as a class template and not just a plain ole’ class that simply inherits from A (see below). It reminds me a little of the CRTP idiom but it’s not the same. Would you happen to know what problems it is intended to solve? Is it some template meta-programming technique?

Well, perhaps you’d understand better if you grabbed yourself a copy of “Modern C++ Design” by Alexandrescu. He describes “Policy Based Design” and the implementations look very much like the code that’s confusing you. I thought there was an excerpt of that part online but I couldn’t find it anywhere now. The book should be on any C++ developer’s shelf anyway.