Should I use a raw pointer here?

I'm building an application, and I am wondering if I should be using a raw pointer, smart pointer, or just the raw value.

Here it is:

class Test
{
public:
    void setSomething()
    {
        map = 
{
    {},
    {} // Values
}
// Concerned here because if I use a raw value than will C++ have to copy all values?
    }
    static Test& getInstance()
    {
        static Test test;
        return test;
    }
private:    
    std::unordered_map<..., ...> map;
};

Now I'm curious about map. The class Test is a singleton, and will only ever be initialized once.

I'm kind of concerned because map can have millions of elements, and I do not want it to copy when I call setSomething. Does this mean I should use a raw pointer or smart pointer for map?



Read more here: https://stackoverflow.com/questions/64897643/should-i-use-a-raw-pointer-here

Content Attribution

This content was originally published by TheUserPerson at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: