Can I assign 0 to a shared_ptr? Why?

Viewed 1315

I realized the following compiles fine in GCC 4.7:

#include <memory>

int main() {
    std::shared_ptr<int> p;
    p = 0;
}

However, there is no assignment operator from int or from int*, and there is no implicit constructor from either int or int* either. There is a constructor from int*, but that one is explicit. I checked the standard library implementation and the constructor is indeed explicit, and no fishy assignment operators are in sight.

Is the program actually well-formed or is GCC messing with me?

2 Answers
Related