我对如何在下面的例子中进行模板参数推断感到困惑.我在本文的其余部分使用术语invoke来暗示实例化和调用.
我专注std::move()于我的自定义类型my_type,我观察到,对于x类型的实例my_type:
std::move(x) 继续调用通用模板std::move(static_cast<my_type&&>(x))或std::move(std::forward(x))调用专业化我的问题是:
这是整个代码:
#include<iostream>
#include<utility>
struct my_type
{
int x;
};
namespace std
{
// This is the std::move() definition in the preprocessor output:
//
// template <class _Tp>
// inline __attribute__ ((__visibility__("hidden"), __always_inline__)) constexpr
// typename remove_reference<_Tp>::type&&
// move(_Tp&& __t) noexcept
// {
// typedef typename remove_reference<_Tp>::type _Up;
// return static_cast<_Up&&>(__t);
// }
// This is std::move() …Run Code Online (Sandbox Code Playgroud)