Код: Выделить всё
#include
using namespace std;
template
class A {
public:
// implicit conversion from int
A(int a) : a_{is_signed ? -a : a}
{}
int a_;
};
bool operator==(A lhs, A rhs) {
return lhs.a_ == rhs.a_;
}
bool operator==(A lhs, A rhs) {
return lhs.a_ == rhs.a_;
}
int main() {
A a1{123};
A a2{123};
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/58508084/how-to-use-template-function-for-implicit-conversion[/url]
Мобильная версия