Use boost::declval instead of std::declval, close #10190.

Thanks-to: Niklas Angare <li51ckf02@...>
Tested-by: Kohei Takahashi <flast@flast.jp>