Boost has something like this:
void OnAccept( const boost::system::error_code & ec)
{
if( ec )
{
...
}
}
error_code is a class. What operator to override to make a class object
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should use the safe bool idiom. This protects from most pitfalls that occur when you simply provide a conversion to
bool.To provide some context: If a type can be implicitly converted to
boolthroughoperator bool() const, a value of that type can be used in comparison expressions where this conversion doesn’t make any sense. The C++11 solution would be an explicit conversion operator.