C++ Example with C++20 Keywords

C++ code posted by Tirthankar Mazumder
created at 02 Sep 22:34

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

template <typename T>
concept Addable = requires (T a, T b) {
    a + b;
};

template <typename T>
T add(const T& a, const T& b) {
    return a + b;
}

int main() {
    std::cout << add(4, 5) << '\n';
}
237 Bytes in 2 ms with coderay