Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

G++: Default Overload For Ambiguous Case

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!

like image 554
Precursor Avatar asked Jan 11 '23 17:01

Precursor


1 Answers

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

like image 125
Bryan Chen Avatar answered Jan 18 '23 21:01

Bryan Chen