Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Overloading classes with concepts

14 views
Skip to first unread message

Bonita Montero

unread,
Jun 10, 2021, 12:45:25 PM6/10/21
to
I can have multiple overloads of a function for multiple concept
-types:

#include <concepts>

using namespace std;

template<floating_point Fp>
void f( Fp fp )
{
}

template<integral Int>
void f( Int i )
{
}

But how can I do that with structs / classes - so I would have
multiple specializations of a class for different concept-types.

Bonita Montero

unread,
Jun 10, 2021, 12:49:21 PM6/10/21
to
Oh, I got it:

template<typename T>
struct S
{
};

template<integral Int>
struct S<Int>
{
};

template<floating_point Fp>
struct S<Fp>
{
};
0 new messages