T
Tim Clacy
Please illuminate; what operator of class 'Event' will get matched for these
two cases [see Event outline later]:
Event ev1;
Event ev2;
// Case 1
//
if (ev1)
;
// Case 2
//
if (ev1 || ev2)
;
I would have thought 'operator int ()' is the only obvious match, but my
compiler generates errors:
"ambiguous 3-way choice of conversion from 'struct Event' in Boolean
context
All I'm trying to do is wrap an OS event in a class that can be treated like
a Boolean; can anyone explain what the ambiguity is and how it can be
resolved (preferable without casts)?
Best regards
Tim
typedef struct tagHandle { }* Handle;
bool eventIsSignalled(Handle hEvent);
struct Event
{
:
bool IsSignalled() const { return eventIsSignalled(*this); }
operator int () const { return IsSignalled(); }
operator Handle () const { return handle; }
private:
Handle handle;
};
two cases [see Event outline later]:
Event ev1;
Event ev2;
// Case 1
//
if (ev1)
;
// Case 2
//
if (ev1 || ev2)
;
I would have thought 'operator int ()' is the only obvious match, but my
compiler generates errors:
"ambiguous 3-way choice of conversion from 'struct Event' in Boolean
context
All I'm trying to do is wrap an OS event in a class that can be treated like
a Boolean; can anyone explain what the ambiguity is and how it can be
resolved (preferable without casts)?
Best regards
Tim
typedef struct tagHandle { }* Handle;
bool eventIsSignalled(Handle hEvent);
struct Event
{
:
bool IsSignalled() const { return eventIsSignalled(*this); }
operator int () const { return IsSignalled(); }
operator Handle () const { return handle; }
private:
Handle handle;
};