Hello,

C++11 introduced references on rvalues, which basically allows to use a
non-constant reference on a temporary object (ie waiting for
affectation). Before, temporary objects could only be references by a
const reference.

Thus, from there, it becomes a problem to have two implicit conversion
operators defined in the class TextLineReader (text_line_reader.h):

        operator const std::string& () const { return line_string() ; }
        operator std::string() const { return line_string(); }

A call such that

        TextLineReader r(...);
        std::string str=r;

becomes ambiguous as the compiler could use the affectation operator of
std::string that take a const std::string& as input (thus calling the
first above operator) *or* the affectation operator of std::string that
takes a reference on a rvalue as input (thus calling the second above
operator, which returns a temporary object).

I suggest removing the second one. The first one is needed, for instance, in

        const std::string& str=r;

which is non-ambiguous, whereas

        std::string str=r;

and

        std::string str(r);

are ambiguous and can work with either of the two implicit conversion
operators of TextLineReader.


I will prepare an upload.

Bye,
Pierre

Reply via email to