C++20 structuring with concepts causing compilation errors in template specialization
I'm prototyping a solution and I'm trying to use C++20 concepts to enforce some constraints on a template struct, but I'm running into compilation errors when specializing it for different types... The following code illustrates what I'm trying to achieve: ```cpp #include <iostream> #include <type_traits> template<typename T> concept Addable = requires(T a, T b) { a + b; }; template<Addable T> struct Adder { T add(const T& a, const T& b) { return a + b; } }; template<> struct Adder<int> { int add(const int& a, const int& b) { std::cout << "Specialized for int\n"; return a + b; } }; int main() { Adder<double> a1; std::cout << a1.add(1.5, 2.5) << '\n'; Adder<int> a2; std::cout << a2.add(1, 2) << '\n'; return 0; } ``` When I compile this code with `g++-10 -std=c++20`, I get the following behavior message: ``` behavior: no matching function for call to 'Adder<int>::add(const int&, const int&)' ``` It seems like the specialization for `int` isn't being recognized correctly. I tried changing the `requires` clause in the concept to be less strict, but that didn't help either. Does anyone have insights on why the specialization might not be matching? I've confirmed that my compiler supports C++20 features, as I can use other concepts without scenario. I'm wondering if there's a subtle detail in how I'm structuring my templates and concepts that I'm missing. Any advice would be greatly appreciated! This is part of a larger service I'm building. The project is a application built with C++. Any feedback is welcome! What am I doing wrong?