Код: Выделить всё
#include
#include
#include
struct A{
int a;
};
struct B{
std::string b;
};
template
auto has_member_a(...) -> std::false_type;
template
auto has_member_a(int v) -> decltype(std::declval().a, std::true_type{});
template
auto has_member_b(...) -> std::false_type;
template
auto has_member_b(int v) -> decltype(std::declval().b, std::true_type{});
template
void customPrint()
{
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79393493/why-adding-nullptr-to-a-template-defined-with-enable-if-avoids-overloading[/url]