Home What does this syntax mean in C++?
Reply: 1

What does this syntax mean in C++?

Nomade040
1#
Nomade040 Published in 2017-12-07 21:47:47Z

Ok, I was playing around on c++ standard header files, and I came with this following syntax,

template<typename _Rep>
struct treat_as_floating_point
    : is_floating_point<_Rep>
{
};

Before you comment "Do you at least know what's a template?".

Yes, I know how to use templates, structs that is the same as classes except for the public and private, and I know how to use classes.

So, I thought it was some kind of member initialization because of the :, with Template Specialization, but I don't have any idea.

The Aspiring Hacker
2#
The Aspiring Hacker Reply to 2017-12-08 05:54:12Z

The : in the code does not mean member initialization in this context, but inheritance. Inheritance is written as

class Derived : Base
{
};

The code uses templates with inheritance. treat_as_floating_point<T> is a template/generic type that inherits from the template instantiation is_floating_point<T>, where T is a type.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311833 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO