なぜこれが起こっているのかよくわかりません。
次のように宣言された関数がいくつかあります。
std::string unmaskString(std::string &oValue);
コードで私はこれを行います:
v = unmaskString(line.substr(eq+1));
そして、次のようなコンパイル エラーが表示されます。
error: invalid initialization of non-const reference of type 'std::string&' from a temporary of type 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
これを2つの別々のステートメントに入れると、うまくいきます:
v = line.substr(eq+1);
v = unmaskString(v);
最初の行は参照ではなく文字列オブジェクトを返すため、エラーの意味がよくわかりません。
機能を
std::string unmaskString(std::string oValue);
また、そのエラーが発生します。
アップデート:
これは間違いだったので、maskString を unmaskString に変更しましたが、masString が同じ署名を持っているため、問題は依然として適用されます。