The main difference between ++var
and var++
is obvious [link].
My question is about their impact on references. Here is the detail: I have a reference to a cuDF::multimap
which is shown in what follows:
found = map->find(key)
When I try to increment that reference, using ++found
works fine. However, using found++
returns this warning:
warning: returning reference to local variable
I understand the meaning of the warning. Can someone explain why I get this warning?
More Details
That is, the following code snippet will generate the aforementioned warning.
found = map->find(key);
while (found != map->end() && found->first != unusedKey) {
std::cout << found->second << std::endl;
found++;
}
However, this doesn't produce any warning:
found = map->find(key);
while (found != map->end() && found->first != unusedKey) {
std::cout << found->second << std::endl;
++found;
}