From the course: Functional Programming in C++
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Combining concepts - C++ Tutorial
From the course: Functional Programming in C++
Combining concepts
- [Instructor] Combining concepts. Concepts can be combined to impose multiple constraints on a single template. So, here we're going to have, you know, we have our standard library packages that we need. We're going to have an arithmetic concept, a concept requiring addition, and then we're going to combine both of those together to constrain our template. All right? So we're going to start off with, as usual, template. And this is going to be a typename of T. And we're going to have a concept called Arithmetic. And it is going to require std::is_arithmetic_v and of T. Now, underneath Concept requiring addition, we're going to have another template of typename T. And this concept is going to be named Addable. And it is going to have requires T of a, T of b. And inside, we're going to have an open and close curly brace. We're going to have an a + b here. And we're going to do another std::convertible_to, and here's another type of T semicolon and another semicolon. And the final bit…