今日也是希望 gcc 赶快有 deducing this 的一天,原因是写了:
Num operator+(const Num& rhs) const & { ... }
Num operator+(const Num& rhs) && { ... }
Num operator+(Num&& rhs) const & { ... }
Num operator+(Num&& rhs) && { ... }Forwarded from Lancern's Treasure Chest
对于上面的 C++ 代码,下面哪一个说法是正确的?
Anonymous Quiz
29%
程序无法通过编译
32%
程序的行为是良定义的
18%
当 condition 为 true 时程序具有未定义行为
21%
无论 condition 的值如何,程序总具有未定义行为
草,原来就叫 std::move
建议加入 std::copy 的 cppreference 底下的 see also
template<typename T>
decltype(auto) avg(T x, T y)
noexcept(noexcept((x + y) / 2))
requires requires { (x + y) / 2; }
{
return (x + y) / 2;
}