2

Can someone please explain what is going on in the code below:

template<class Thermo, template<class> class Type>
class thermo
:
    public Thermo,
    public Type<thermo<Thermo, Type>> // <-- this is what I don't get
{

Here is what I don't get:

1-class thermo inherits from Type<thermo<Thermo, Type>> while has a template argument of itself (Type<thermo<Thermo, Type>>)

2-Type takes itself as an argument in Type<thermo<Thermo, Type>>

Thanks in advance.

Ryan.
  • 21
  • 2
  • "*Here is what I don't get:*" Didn't you already correctly describe what this did? – 康桓瑋 Jan 17 '22 at 09:41
  • maybe it helps to think of `Type>` as a new type that resulted from instantiating `Type` and forget about that it came from the template, call it `B`, then `thermo` inherits from `Thermo` and from `B`. – 463035818_is_not_an_ai Jan 17 '22 at 09:44
  • @康桓瑋 I just described what I saw but I don't understand why/how it works and what is its application in general. For instance, in class thermo, it needs to pass itself. Is it some sort of recursive definition of the class thermo? – Ryan. Jan 17 '22 at 09:49

0 Answers0