为什么在gcc的is_nothrow_constructible实现中需要static_cast?

问题描述 投票:11回答:1

取自type_traits的GCC实施,为什么这里需要static_cast

template <typename _Tp, typename... _Args>
struct __is_nt_constructible_impl
    : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> {};

template <typename _Tp, typename _Arg>
struct __is_nt_constructible_impl<_Tp, _Arg>
    : public integral_constant<bool,
                               // Why is `static_cast` needed here?
                               noexcept(static_cast<_Tp>(declval<_Arg>()))> {};
c++ typetraits libstdc++ static-cast
1个回答
12
投票

如果发明的变量声明

© www.soinside.com 2019 - 2024. All rights reserved.