Created
February 26, 2025 21:52
-
-
Save Zaryob/67b2aff2dcbe463a41c9806ab3cc24b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <concepts> | |
#include <iostream> | |
template <typename T> | |
concept Addable = requires(T a, T b) { | |
a + b; | |
}; | |
void addAndPrint(Addable auto a, Addable auto b) { | |
std::cout << a + b << std::endl; | |
} | |
int main() { | |
addAndPrint(3, 4); // Geçerli | |
// addAndPrint(3, "Hi"); // Derleme hatası | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment