Question

Given two functions, like so

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);

the overload is obviously ambiguous for cases like GS(float, float, int, int)

Is there any way I can specify a default overload for cases like this? Doesn't have to be compatible with anything but the GNU C++ compiler, as I'm already using several unique conventions. Ideally, something like

inline V2T<Int16> GS(... , Uint8 f = 0x00) __default;
inline V2T<Int16> GS(... , int maxW = -1, int maxH = -1, Uint8 f = 0x00);

causing the compiler to automatically resolve in favor of the first (__default) function.

All questions I've seen have been oriented towards newbies encountering this error for the first time, so it's possible this has been answered but buried. Thanks in advance!

Was it helpful?

Solution

try this

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);

you can see result here

OTHER TIPS

The most obvious fix is

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, int maxH = -1, Uint8 f = 0x00);

since your intention is that maxW can't actually be given a default value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top