Template classes and inheritance

Discussion in 'C++' started by Joerg Loosen, Oct 7, 2004.

  1. Joerg Loosen

    Joerg Loosen Guest

    Hi there!

    I recently found this code in a framework class:

    class derived : base<derived> {
    // ...
    }

    I. e. a class derived from a template class whose template parameter is
    the derived class itself.

    I remember vaguely having read something about this construct, but I
    cannot recall where. Does this pattern have a name with which I could
    try a web search? Or could somebody explain it to me?

    Thanks,

    Joerg
    Joerg Loosen, Oct 7, 2004
    #1
    1. Advertising

  2. Joerg Loosen

    Sharad Kala Guest

    "Joerg Loosen" <> wrote in message
    > Hi there!
    >
    > I recently found this code in a framework class:
    >
    > class derived : base<derived> {
    > // ...
    > }
    >
    > I. e. a class derived from a template class whose template parameter is
    > the derived class itself.
    >
    > I remember vaguely having read something about this construct, but I
    > cannot recall where. Does this pattern have a name with which I could
    > try a web search? Or could somebody explain it to me?



    Curiously Recurring Template Pattern (CRTP) (by Jim Coplien, AFAIK). Do a
    search on this group and you will find many threads on CRTP.

    Sharad
    Sharad Kala, Oct 7, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ian
    Replies:
    5
    Views:
    518
  2. claude uq
    Replies:
    3
    Views:
    498
    tom_usenet
    Dec 18, 2003
  3. Replies:
    5
    Views:
    337
    James Kanze
    Apr 27, 2007
  4. Thomas Witkowski
    Replies:
    2
    Views:
    348
    James Kanze
    Aug 6, 2007
  5. Rouslan Korneychuk
    Replies:
    8
    Views:
    589
    Rouslan Korneychuk
    Feb 10, 2011
Loading...

Share This Page