Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Template classes and inheritance

Reply
Thread Tools

Template classes and inheritance

 
 
Joerg Loosen
Guest
Posts: n/a
 
      10-07-2004
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
 
Reply With Quote
 
 
 
 
Sharad Kala
Guest
Posts: n/a
 
      10-07-2004

"Joerg Loosen" <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with inheritance of classes with template parameter Thomas Witkowski C++ 2 08-06-2007 08:16 PM
types of classes in template classes lobequadrat@googlemail.com C++ 5 04-27-2007 05:33 PM
what to do with template classes in template unsupported compiler ? Shlomi C++ 5 05-20-2004 07:42 AM
template functions calls within non template classes. How to do it? claude uq C++ 3 12-18-2003 04:55 PM
implementing policy classes with template template parameters ian C++ 5 10-09-2003 03:19 PM



Advertisments