mardi 29 octobre 2019

Why does make_shared allocate same address in separate calls?

Why does this make_shared allocate the same memory address in two separate calls?

typedef struct {
    int a;
    int b;
    int c;
} test_t;

void call_func()
{
    std::shared_ptr<test_t> tst = std::make_shared<test_t>();

    std::cout << "addr: " << tst << std::endl;
}

int main()
{
    call_func();
    call_func();
}

Here it is online: http://coliru.stacked-crooked.com/a/ffc92bc131009402

Aucun commentaire:

Enregistrer un commentaire