null値のshared_ptr

melponnさんにコメントをいただいたので早速使ってみた。

#include <iostream>
#include <string>
#include <vector>
#include <memory>

using namespace std;
using namespace std::tr1;

int main() {
  typedef shared_ptr<string> strp;
  vector<strp> v;

  v.push_back(strp(new string("foo")));
  v.push_back(strp(static_cast<string *>(0)));
  v.push_back(strp(new string("bar")));
  v.push_back(strp(static_cast<string *>(0)));
  v.push_back(strp(new string("zoo")));

  for (vector<strp>::const_iterator i = v.begin(); i != v.end(); i++) {
    shared_ptr<string> p = *i;
    if (p) {
      cout << *p << endl;
    } else {
      cout << "-" << endl;
    }
  } 

  return 0;
}


foo
-
bar
-
zoo
続行するには何かキーを押してください . . .
うまくいってるようだけど、null値のshared_ptrって大丈夫なのかな?
あどで調べてよう。