Listing 5

#include <memory>
#include <iostream>
using std::tr1::shared_ptr;
using std::cout;

int main()
  { // demonstrate operator boolean-type()
  shared_ptr<int> sp;
  if (sp)
    cout << "not empty\n";
  else
    cout << "empty\n";
  sp.reset(new int());
  cout << (sp ? "not " : "") << "empty\n";
  return 0;
  }