Home
Blogs
Questions
Jobs
Monetize

Home

About Us

Blogs

Questions

Jobs

Monetize

Post Job

banner

Questions about weak-ptr

Read more about weak-ptr

python (12.9k questions)

javascript (9.2k questions)

reactjs (4.7k questions)

java (4.2k questions)

java (4.2k questions)

c# (3.5k questions)

c# (3.5k questions)

html (3.3k questions)

Questions - weak-ptr

About shared_mutex and shared_ptr across multiple threads

I implemented code such that multiple instances running on different threads reads other instances' data using reader-writer lock and shared_ptr. It seemed fine, but I am not 100% sure about that and ...
test-img

torano

c++

multithreading

shared-ptr

weak-ptr

readerwriterlock

Votes: 0

Answers: 1

Latest Answer

I have several remarks: ~ChunkData: You could change your data member from int* to unique_ptr<int[]> to get the same result without an explicit destructor. Your code is correct though, just les...
test-img

Homer512

Calling `.lock()` on weak_ptr returns NULL shared_ptr

I am somewhat confused by the behaviour of the .lock() call on a weak_ptr. My understanding is that .lock() will return a shared_ptr of the relevant type if it has not expired otherwise it will be a ...
test-img

Paul

c++

c++14

weak-ptr

Votes: 0

Answers: 1

Latest Answer

Weak pointer attaches only to existing shared pointers, by itself weak pointer doesn't hold or create any object pointer. In other words if you do: std::weak_ptr<int> wp; auto sp = wp.lock(); t...
test-img

Arty

Posts

Questions

Blogs

Jobs

The ultimate platform for coders and IT specialists

About

  • Company
  • Support

  • Platform

  • Terms & Conditions
  • Privacy statement
  • Cookie policy
  • Cookie option
  • OnlyCoders © 2025  |  All rights reserved