Skip to content

Commit

Permalink
Replace operator safe_bool with explicit operator bool
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Jan 27, 2024
1 parent f898d3a commit af8e66d
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions include/boost/function/function_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,24 +810,7 @@ namespace boost {
}
}

#if (defined __SUNPRO_CC) && (__SUNPRO_CC <= 0x530) && !(defined BOOST_NO_COMPILER_CONFIG)
// Sun C++ 5.3 can't handle the safe_bool idiom, so don't use it
operator bool () const { return !this->empty(); }
#else
private:
struct dummy {
void nonnull() {}
};

typedef void (dummy::*safe_bool)();

public:
operator safe_bool () const
{ return (this->empty())? 0 : &dummy::nonnull; }

bool operator!() const
{ return this->empty(); }
#endif
explicit operator bool () const { return !this->empty(); }

private:
void assign_to_own(const BOOST_FUNCTION_FUNCTION& f)
Expand Down

0 comments on commit af8e66d

Please sign in to comment.