I try to check template class T
in function do_math()
on the possibility of throwing an exception in the copy assignment operator.
But the following code throws an error:
template<class T>
void do_math()
noexcept(noexcept(T(std::declval<T>())) && noexcept(std::declval<T>() + std::declval<T>()) && noexcept(std::declval<T>().operator = (std::declval<T>())) )
{
}
main.cpp:9:135: error: request for member ‘operator=’ in ‘std::declval<int>()’, which is of non-class type ‘int’
noexcept(noexcept(T(std::declval<T>())) && noexcept(std::declval<T>() + std::declval<T>()) && noexcept(std::declval<T>().operator = (std::declval<T>())) )
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
Please help me to write the correct check.