In answer to my previous question I learned that C++ 20 concepts do not allow overloading on struct template arguments, for example this does not work:
#include <concepts>
template <std::integral>
struct S{
};
template <std::floating_point>
struct S{
};
For curious clang error is something like, but that does not matter since I know C++ standard does not allow this code to work:
type constraint differs in template redeclaration
I find this nonworking way of writing templates very natural so I wonder was this ever considered, and if so why it was rejected during standardization?
P.S. this seems to work in C++20, but I find it much uglier
#include <concepts>
#include <iostream>
template <typename T>
requires std::integral<T> || std::floating_point<T>
struct S{
};
template <std::integral T>
struct S<T>{
static constexpr char msg[] = "i";
};
template <std::floating_point T>
struct S<T>{
static constexpr char msg[] = "fp";
};
int main() {
std::cout << S<char>::msg << std::endl;
std::cout << S<double>::msg << std::endl;
}