A
Alexander Stippler
Hi,
I've got a question concerning iterators and STL. Why does the compiler
warn, that function dummy in the following example returns a reference
to a local temporary? In my understanding, it is not temporary. It's an
entry in a hash_map and therefore not temporary. Where am I wrong? How do I
get the desired functionality?
And by the way: Does anybody know a real in-depth reference and programming
guide for understanding and above all extending the STL by own data types?
#include <hash_map>
#include <pair.h>
#include <iostream>
std::hash_map<int,int> hash;
const std:air<int,int> &
dummy(int key) {
return *(hash.find(key));
}
int
main()
{
hash[8] = 9;
dummy(8);
return 0;
}
regards,
Alex
I've got a question concerning iterators and STL. Why does the compiler
warn, that function dummy in the following example returns a reference
to a local temporary? In my understanding, it is not temporary. It's an
entry in a hash_map and therefore not temporary. Where am I wrong? How do I
get the desired functionality?
And by the way: Does anybody know a real in-depth reference and programming
guide for understanding and above all extending the STL by own data types?
#include <hash_map>
#include <pair.h>
#include <iostream>
std::hash_map<int,int> hash;
const std:air<int,int> &
dummy(int key) {
return *(hash.find(key));
}
int
main()
{
hash[8] = 9;
dummy(8);
return 0;
}
regards,
Alex