W
wij
Hi:
I have a class for return status, it contains a pointer member.
Now, I'd like to add two members operator const void*() and
bool operator!() like the case in std::basic_ios, to ease the test.
class Ret {
RetInfo* _p;
public:
Ret(int error_no);
operator const void*() const;
bool operator!() const;
}
So applications can say:
extern Ret f();
if(f()) {.....}
if(!(r=f())) {.....}
Because the purpose is mostly to shorten condition test statements.
Is there any known unwanted side effect or how good it is in practice?
I have a class for return status, it contains a pointer member.
Now, I'd like to add two members operator const void*() and
bool operator!() like the case in std::basic_ios, to ease the test.
class Ret {
RetInfo* _p;
public:
Ret(int error_no);
operator const void*() const;
bool operator!() const;
}
So applications can say:
extern Ret f();
if(f()) {.....}
if(!(r=f())) {.....}
Because the purpose is mostly to shorten condition test statements.
Is there any known unwanted side effect or how good it is in practice?