関数内で unordered_set にデータを格納し、格納されているオブジェクトへのポインターを返す場合、ポインターは関数のスコープ外でも有効ですか?
例えば。
int *myFunc(){
std::unordered_set<int> hashset;
//add some objects
hashset.insert(4);
hashset.insert(5);
hashset.insert(6);
int *intptr = &(*hashset.insert(4)); //try to insert an object that may already be in the set, and get a pointer to the object in the set
return intptr;
}
*intptr別の関数でアクセスしようとするとエラーになりますか? または、unordered_set のスコープが終了すると、unordered_set 内のデータの割り当てが解除されますか?