给定两个函数,像这样
inline V2T<Int16> GS(float x, float y, int xOff, int yOff, Uint8 f = 0x00);
inline V2T<Int16> GS(float x, float y, int xOff, int yOff, int maxW = -1, int maxH = -1, Uint8 f = 0x00);
对于像 GS(float, float, int, int) 这样的情况,重载显然是模棱两可的
有什么方法可以为这种情况指定默认重载吗?不必与 GNU C++ 编译器兼容,因为我已经在使用几个独特的约定。 理想情况下,像
inline V2T<Int16> GS(... , Uint8 f = 0x00) __default;
inline V2T<Int16> GS(... , int maxW = -1, int maxH = -1, Uint8 f = 0x00);
使编译器自动解析以支持第一个 (__default) 函数。
我看到的所有问题都是针对第一次遇到这个错误的新手,所以这可能已经被回答但被埋没了。提前致谢!
最佳答案
试试这个
inline V2T<Int16> GS(float x, float y, int xOff, int yOff, Uint8 f = 0x00);
// this one is not default one
template <class = void>
inline V2T<Int16> GS(float x, float y, int xOff, int yOff, int maxW = -1, int maxH = -1, Uint8 f = 0x00);
可以看到结果here
关于c++ - G++:不明确案例的默认重载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23354166/