|
|
От: |
Sm0ke
|
ksi |
| Дата: | 26.07.23 13:01 | ||
| Оценка: | |||
V>template<class T>
V>const T& max(const T& a, const T& b)
V>{
V> return (a < b) ? b : a;
V>}
V>Notes
Capturing the result of std::max by reference produces a dangling reference if one of the parameters is a temporary and that parameter is returned:
int n = 1;
const int& r = std::max(n — 1, n + 1); // r is dangling