title: How to use boost::optional<T> to return NULL in C++?
body: <p>I have a function that needs to return NULL in some cases and there is another function that needs to test for the return value of this function. I am aware of boost::optional but am not sure how to use the syntax.</p>
  
  <p>Below would be a simple example of said usage:</p>
  
  <pre><code>int funct1(const string&amp; key) {
    // use iterator to look for key in a map
    if(iterator == map.end()) {
      return NULL // need help here!
    else
      return it-&gt;second;
  }
  
  void funct2(string key) {
    if(funct1(key) == NULL) { // &lt;-- need help here!
      // do something
    } else {
      // do something else
    }
  </code></pre>
  
  <p>Can someone please help with the syntax?</p>
  
  <p>Thanks.</p>