1

I saw C++ code like this:

if(bool(function_pointer)) 

Where function_pointer is

typedef boost::function<bool (const int&)> Checker;

I'm wondering what's the difference between

 bool(function_pointer) 

and

(bool)function_pointer
Tas
  • 7,023
  • 3
  • 36
  • 51
  • 3
    Those are both [*explicit type conversions*](http://en.cppreference.com/w/cpp/language/explicit_cast) and mean the same thing. – Some programmer dude Apr 04 '18 at 06:19
  • The casting is also not needed. If used when a boolean value is expected (like in a condition) then [`std::function`](http://en.cppreference.com/w/cpp/utility/functional/function) have an [`operator bool`](http://en.cppreference.com/w/cpp/utility/functional/function/operator_bool) that should be used automatically by the compiler. – Some programmer dude Apr 04 '18 at 06:20

0 Answers0