Constraining Class Templates

Learn about constraining class templates in C++20.

Class templates and class template specializations can also be constrained just like function templates. To start, we’ll consider the wrapper class template again, but this time with the requirement that it should only work for template arguments of integral types. This can be simply specified in C++20 as follows:

Get hands-on with 1400+ tech skills courses.