Lwartość referencyjnego wiązania rvalue
Kompilator wciąż narzeka Próbuję powiązać wartość l z referencją rvalue, ale nie widzę, jak. Jestem nowicjuszem w C ++ 11, poruszam semantykę, itd., Więc proszę o wyrozumiałość.
Mam tę funkcję:
template <typename Key, typename Value, typename HashFunction, typename Equals>
Value& FastHash<Key, Value, HashFunction, Equals>::operator[](Key&& key)
{
// Some code here...
Insert(key, Value()); // Compiler error here
// More code here.
}
która nazywa tę metodę:
template <typename Key, typename Value, typename HashFunction, typename Equals>
void FastHash<Key, Value, HashFunction, Equals>::Insert(Key&& key, Value&& value)
{
// ...
}
Ciągle otrzymuję błędy, takie jak:
cannot convert argument 1 from 'std::string' to 'std::string &&'
w wywołaniu Insert (). Nie jestkey
zdefiniowane jako wartość r przeciążenia operatora? Dlaczego jest reinterpretowany jako lwartość?
Dzięki.