即将在 c++ fix/alleviate 中添加模块是否需要 pimpl 惯用语?

Will the upcoming addition of modules in c++ fix/alleviate the need for the pimpl idiom?

据我所知,pimpl 惯用语在前向声明的符号名称后面隐藏了一个私有实现,因此它可以在私有 cpp 模块中声明和使用。

示例:https://cpppatterns.com/patterns/pimpl.html

据我所知,因为 class hosint pimpl 需要了解其结构(大小、对齐),pimpl 必须通过某种指针间接访问。

(或分配为足够大小的块,然后 moved/created 进入稍后由 cast 重新解释的位置。)

即将发布的模块规范是否以任何方式解决了这个问题?

P0142R0

5.2.3 Exported Class Properties

An occasionally vexing rule of standard C++ is that of controls access, not visibil- ity. E.g. a private member of a class is visible to, but not accessible to non-member entities. In particular, any change to a private member of a class is likely to trigger e-processing of any translation unit that depends on that class’s definition even if the change does not affect the validity of dependent units. It is tempting to solve that problem with a module system. However, having two distinct sets of rules (visibility and accessibility) for class members strikes us as undesirable and poten- tially fertile source of confusion. Furthermore, we want to support mass-migration of existing codes to modules without programmers having to worry about class member name lookup rules: if you understand those rules today, then you do not have to learn new rules when you move to modules and you do not have to worry about how the classes you consume are provided (via modules or non-modules).

Rule 3 In general, any property of a class (e.g. completeness) that is computed in the export declaration part of a module is made available to importing modules as is.

由于 class 的所有属性对导入器都是可见的,因此对这些属性的任何更改在导入器中都是可见的。我没有看到模块解决了 PIMPL 解决的问题。