title: C++11 Magic to test and assign from pointer if not nullptr
body: <p>Okay, I believe in defensive programming.  I assume that if I get a pointer it might be null (especially when using GSOAP).  Therefore before I try to use the value of the pointer, I always check to make sure the pointer is not null.</p>
  
  <p>In my current code, this is leading to a lot of nearly identical statements.</p>
  
  <pre><code>if (res-&gt;A) {
      item.out_trace-&gt;a = *res-&gt;A;
  }
  if (res-&gt;B) {
      item.out_trace-&gt;b = *res-&gt;B;
  }
  if (res-&gt;C) {
      item.out_trace-&gt;b = *res-&gt;C;
  }
  </code></pre>
  
  <p>I realize that I could always go and define a macro for this, but I am wondering if there is a neat C++11 trick to do that.  I would love something like the C# <code>??</code></p>
  
  <pre><code>// Set y to the value of x if x is NOT null; otherwise, 
  // if x = null, set y to -1. 
  int y = x ?? -1;
  </code></pre>
  
  <p>Thanks.</p>