Curiously Recurring Template Pattern - Pitfalls

Pitfalls

One issue with CRTP is that the correct usage of the pattern by derived classes cannot be checked at compile time. For example, with the above example of Shape_CRTP, if the definition of Circle were changed to:

class Circle: public Shape_CRTP {};

, it would still compile with no errors. However, running code that performs clone on a Circle object will lead to undefined behavior.

Read more about this topic:  Curiously Recurring Template Pattern

Famous quotes containing the word pitfalls:

    Because relationships are a primary source of self-esteem for girls and women, daughters need to know they will not lose our love if they speak up for what they want to tell us how they feel about things. . . . Teaching girls to make specific requests, rather than being indirect and agreeable, will help them avoid the pitfalls of having to be manipulative and calculating to get what they want.
    Jeanne Elium (20th century)