In this post, we will see how to resolve Is there a way to remove reference, cv qualifiers, and pointerness of a type to make it plain? Question: Take the following code: I would want the domain of passFoo to ...

In this post, we will see how to resolve Can I use C++20 concepts for partial template specialization? Question: I was given an assignment on my computer science class to implement a String<T> class in C++ which would have print ...

In this post, we will see how to resolve Changing position of C++20 “requires clause” gives different results Question: Consider the following type MyType together with a SFINAE-style detection whether some type U is MyType or not: Then I define ...

In this post, we will see how to resolve C++20 concepts: accumulate values of all good types passed to function variadic template Question: I write a function variadic template that can be used like this: Using binary operator+ Accum accumulates ...

In this post, we will see how to resolve C++20 concepts as Interfaces Question: Hey I’m trying to design some Interfaces without any runtime overhead using c++20 concepts. I came up with the following (simplified) concept Since every OS has ...

Question: When defining c++20 concepts to check that requirements are fulfilled by calling a constrained function the behavior is different in g++ and clang. g++ accept a type if the checking function is invalid, clang does the opposite: Checking the ...

Question: I have a variadic function that can take any combination of input arguments, as long as each one of those arguments is convertible to bool: I have attempted to constrain the templates using concepts to only allow bool-convertible types ...

Question: I would like to define a concept that indicates a type is one of several supported types. I can do this by repeatedly listing the types with std::same_as<T, U>: Is there a more concise way to write this without ...

Question: The standard library doesn’t seem to provide a concept for character types yet. Similar to e.g. std::integral, I want a concept that is suitable for character types (such as char, wchar_t, char32_t, etc.). How should one write a proper ...

Question: I’m trying to write a concept that instantiates a function if the template parameter is only of numeric type (integers, floats, doubles and so on) and throw an error if the type is a pointer type or a boolean ...