fork(1) download
  1. #include <iostream>
  2. #include <memory>
  3.  
  4. int main()
  5. {
  6. using namespace std;
  7. int *raw_pointer = new int(42);
  8. shared_ptr<int> shared_pointer(raw_pointer);
  9. weak_ptr<int> weak_pointer(shared_pointer);
  10. cout << boolalpha << (weak_pointer.lock().get() == raw_pointer) << '\n';
  11. }
Success #stdin #stdout 0s 3232KB
stdin
Standard input is empty
stdout
true