title: Is there a way to pass a string literal as reference in C++
body: <p>Within C++ it is common to pass by reference instead of pointer if a value can not be NULL. </p>
  
  <p>Suppose I have a function with the following signature, which is often used with a string literal. </p>
  
  <pre><code>void setText( const char* text );
  </code></pre>
  
  <p>I was wondering how I could change the function in such a way that it accepts a reference (and has the advantage not to accept NULL)?</p>
  
  <ul>
  <li><p>If I would change it to <code>(const char&amp; text)</code> then it would be a ref to a single char. From which the address can ba taken inside the function... but feels not nice. </p></li>
  <li><p>Another option would be <code>(const std::string&amp; text)</code> which has the disadvantage that it always calls a constructor and does some dynamic memory allocation. </p></li>
  </ul>
  
  <p>Any other common ways, or just stick to the <code>std::string&amp;</code> or the <code>char*</code> ?</p>