Is the pImpl idiom really used in practice?

后端 未结 11 1430
渐次进展
渐次进展 2020-11-22 17:21

I am reading the book \"Exceptional C++\" by Herb Sutter, and in that book I have learned about the pImpl idiom. Basically, the idea is to create a structure for the p

11条回答
  •  庸人自扰
    2020-11-22 17:38

    It is used in practice in a lot of projects. It's usefullness depends heavily on the kind of project. One of the more prominent projects using this is Qt, where the basic idea is to hide implementation or platformspecific code from the user (other developers using Qt).

    This is a noble idea but there is a real drawback to this: debugging As long as the code hidden in private implemetations is of premium quality this is all well, but if there are bugs in there, then the user/developer has a problem, because it just a dumb pointer to a hidden implementation, even if he has the implementations source code.

    So as in nearly all design decisions there a pros and cons.

提交回复
热议问题