title: Clang ambiguity with custom conversion operator
body: <p>I've been developing a kind of adapter class, when I encountered a problem under clang. When both conversion operators for lvalue-reference and rvalue reference are defined you get an ambiguity compilation error trying to move from your class (when such code should be fine, as </p>
  
  <pre><code>operator const T&amp; () const&amp;
  </code></pre>
  
  <p>is allowed only for lvalues AFAIK). I've reproduced error with simple example:</p>
  
  <pre><code>#include &lt;string&gt;
  
  class StringDecorator
  {
  public:
    StringDecorator()
    : m_string( "String data here" )
    {}
  
    operator const std::string&amp; () const&amp; // lvalue only
    {
      return m_string;
    }
  
    operator std::string&amp;&amp; () &amp;&amp; // rvalue only
    {
      return std::move( m_string );
    }
  
  private:
      std::string m_string;
  };
  
  void func( const std::string&amp; ) {}
  void func( std::string&amp;&amp; ) {}
  
  int main(int argc, char** argv)
  {
    StringDecorator my_string;
  
    func( my_string ); // fine, operator std::string&amp;&amp; not allowed
    func( std::move( my_string ) ); // error "ambiguous function call"
  }
  </code></pre>
  
  <p>Compiles fine on gcc 4.9+, fails on any clang version.
  So the question: is there any workaround? Is my understanding of <em>const&amp;</em> function modifier right?</p>
  
  <p>P.S.: To clarify - the question is about fixing StringDecorator class itself (or finding the workaround for such class as if were a library code). Please refrain providing answers that call operator T&amp;&amp;() directly or specify conversion type explicitly.</p>