A Method that returns "const std::string&" with error cheking
<p>I am writing a function, which I want to return "const std::string&amp;". Let's just look at the codes.</p>

<pre><code>class A
{
public:
    const std::string&amp; GetString() const
    {
        if (list.empty())
        {
            return "Warning!";    // how to get around this line.
        }
        return list[0];
    };
protected:
    std::vector&lt;std::string&gt; list;
};
</code></pre>

<p>The above codes are an example. The basic idea is to write a function that returns const reference, but also able to check for errors.</p>

<p>So, how to get around "return "Warning!";"?</p>

<p>Thanks,</p>
