Skip to content

Instantly share code, notes, and snippets.

@Zaryob
Created February 26, 2025 21:52
Show Gist options
  • Save Zaryob/67b2aff2dcbe463a41c9806ab3cc24b6 to your computer and use it in GitHub Desktop.
Save Zaryob/67b2aff2dcbe463a41c9806ab3cc24b6 to your computer and use it in GitHub Desktop.
#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