Pimpl idiom without using dynamic memory allocation

后端 未结 7 1361
独厮守ぢ
独厮守ぢ 2020-12-12 21:00

we want to use pimpl idiom for certain parts of our project. These parts of the project also happen to be parts where dynamic memory allocation is forbidden and this decisio

7条回答
  •  情深已故
    2020-12-12 21:34

    If you can use boost, consider boost::optional<>. This avoids the cost of dynamic allocation, but at the same time, your object will not be constructed until you deem necessary.

提交回复
热议问题