#include <memory>
void f1(std::shared_ptr<bool> ptr) {}
int main() {
f1(0); // OK
f1(1); // compilation error: could not convert ‘1’ from ‘int’ to ‘std::shared_ptr<bool>’
}
Both as int, why 0 but 1 can be converted to std::shared_ptr<T>?
How the disability of conversion from 1 to std::shared_ptr<T> be checked when compiling?
Aucun commentaire:
Enregistrer un commentaire