Access






Access

function::operator boolean-type() const;

The member operator returns an object of an unspecified type that is convertible to bool; the converted value is false only if *this is empty.

Figure. Member operator boolean-type (funobjfun/boolean.cpp)

#include <functional>
#include <iostream>
#include <math.h>
using std::tr1::function;
using std::cout;

void report (const char *title, bool val)
  { // report state of function object
  cout << title << ": object is ";
  if (val)
    cout << "not ";
  cout << "empty\n";
  }

int main ()
  { // demonstrate conversion to boolean type
  function <float(float)> fn;           // construct empty object
  report("after construction", fn);
  fn = cosf;                            // assign target object
  report("after assigning target object", fn);
  fn = 0;                               // assign null pointer
  report("after assigning null pointer", fn);
  return 0;
  }



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows