, , T, int, float.
, , T, typename template, Set.
, Point<int>, one Set, int. Point<T> Set(T,T).
Set, Set , :
template <typename T>
class Point
{
public:
template <typename Num>
void Set(Num x, Num y);
};
, .
, float, double long double... .
- :
template <typename Integral>
template <typename Num>
void Point<Integral>::Set(Num x, Num y)
{
this->x = long double(x) + 0.5;
this->y = long double(y) + 0.5;
}
int al, , . , , .
, , Point<float>, , . std::numeric_limits<T> a is_integer, , .
template <typename T>
template <typename Num>
void Point<T>::Set(Num x, Num y)
{
if (std::numeric_limits<T>::is_integer &&
!std::numeric_limits<Num>::is_integer)
{
this->x = x + 0.5;
this->y = y + 0.5;
}
else
{
this->x = x;
this->y = y;
}
}
}
, if , ... , , if ;)