Implicit type conversion rules in C++ operators
列出C++的隐式类型转换。
所以问题是,是否有一种类型特质可以做到这一点?类似的东西
template <typename T, typename J>
struct promotion_type
{
typedef decltype(operator+(const T&,const J&)) type;
};
(这不是我的问题,但它无法编译:
/home/user/source/testdir/main.cpp:97:51: error: there are no arguments to 'operator+' that depend on a template parameter, so a declaration of 'operator+' must be available [-fpermissive]
typedef decltype(operator+(const T&,const J&)) type;
^
/home/user/source/testdir/main.cpp:97:51: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
)