How to make boost::make_shared a friend of my class

后端 未结 6 1322
借酒劲吻你
借酒劲吻你 2021-02-03 12:28

I have written a class with protected constructor, so that new instances can only be produced with a static create() function which returns shared_ptr\'s to my class. To provide

6条回答
  •  离开以前
    2021-02-03 13:11

    I think that is not the right place to use make_shared. Just construct your object with operator new and pass the pointer to shared_ptr constructor. That way you don't need to be friends with anyone.

    BTW, why template arguments and function arguments are of different type?

提交回复
热议问题