This question already has an answer here:
Disclaimer: I am new to c++.
I have a code block like this:
using BucketType = std::unordered_set<Bucket, BucketHash, BucketEqual>;
const BucketType& Range::buckets(int64_t value) {
BucketType buckets;
...
return std::move(buckets);
}
The caller calls this code like this:
Range range;
auto buckets = range.buckets(11);
Problem:
When I return the reference of the buckets like the code above, the buckets.size()
gives 140732261909672
however, I am only adding 2 buckets in my actual logic. When I change the code to return value instead of reference, it works perfectly fine.
Any pointers on what might be wrong with this code?
Aucun commentaire:
Enregistrer un commentaire