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
Post a Comment