C++Guns – RoboBlog

28.04.2021

C++ Guns: mit concepts zur Compilezeit testen, ob ein enum ein bestimmten enumerator hat

Filed under: Allgemein — Tags: — Thomas @ 09:04

Ja concepts sind schon toll ;)

Grüße an euIRCnet #c++

enum class A {aa, bb};
enum class B {bb};
enum class C {aa, bb};


template<typename T>
struct Isso {
    const static bool value = false;
};


template<typename T>
requires T::aa == T::aa
struct Isso<T> {
    const static bool value = true;
};


static_assert(Isso<A>::value);
static_assert(Isso<B>::value == false);
static_assert(Isso<C>::value);

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress