c++ - PIMPL idiom and copy semantic -


i'm using library contains lot of classes builded using pimpl idiom. found bad, in opinion, classes implemented using std::shared_ptr implementation. means objects "implicitly shared". question is: correct way implement pimpl? or pimpl , "implicitly shared" 2 different idioms , therefore should not mixed default? correct way handle copy semantic?

imo, correct way implement pimpl use std::unique_ptr. it's more efficient , pimpl object should uniquely owned visible class, not shared (and don't have bother copy semantic).

pimpl , "implicitly shared" 2 different idioms indeed.

if still have use std::shared_ptr pimpl have explicitly define copy assignement operations (because compiler won't able generate correct ones).


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -