"d"在d指针中代表什么?
What does "d" stand for in d-pointer?
Qt 在其开发过程中大量使用 PIMPL 习语:https://wiki.qt.io/D-Pointer
据我阅读here:"The name 'd-pointer' stems from Trolltech's Arnt Gulbrandsen, who first introduced the technique into Qt, making it one of the first C++ GUI libraries to maintain binary compatibility even between bigger release."。但是没有人说 "D" 代表什么。
那么"D"在D指针中代表什么?
从这个页面 Data Sharing with Class(来自 QT 的旧文档),它说:
Before we can share an object's private data, we must separate its interface from the private data using an idiom called "d-pointer" (data pointer)
所以,d-pointer 表示数据指针
我会添加我自己的答案,因为我记得它发生的那一天。
我试图在保持二进制兼容性的同时扩展某些内容,并注意到有一个名为 'data' 的指针,我可以将其重新用于不同的目的。所以我为 implementation-related 数据(一个 pimpl)创建了一个私有的 class,将旧数据和我的新数据都放在那里,因为现有名称似乎合适我保留了名称。
在同一天晚些时候的一次简短会议后,我将它从 data 缩写为 d,我们一致认为我 发明 偶然发现的模式很好,我们应该使用它被广泛使用,并且 d->
足够短且足够独特,可以在任何地方用作 implementation-specific 字段的标记。
在同一次会议上,我们决定从那时起将 implementation-specific 数据作为一项政策放在 d-> 中,主要是为了减少包含的数量,同时也保持声明API 总体来说很干净。 class 声明中的私有变量越少,意味着出错的机会越少、诱惑越少、与 subclass 命名冲突的东西越少等等。更好的卫生。
Qt 在其开发过程中大量使用 PIMPL 习语:https://wiki.qt.io/D-Pointer
据我阅读here:"The name 'd-pointer' stems from Trolltech's Arnt Gulbrandsen, who first introduced the technique into Qt, making it one of the first C++ GUI libraries to maintain binary compatibility even between bigger release."。但是没有人说 "D" 代表什么。
那么"D"在D指针中代表什么?
从这个页面 Data Sharing with Class(来自 QT 的旧文档),它说:
Before we can share an object's private data, we must separate its interface from the private data using an idiom called "d-pointer" (data pointer)
所以,d-pointer 表示数据指针
我会添加我自己的答案,因为我记得它发生的那一天。
我试图在保持二进制兼容性的同时扩展某些内容,并注意到有一个名为 'data' 的指针,我可以将其重新用于不同的目的。所以我为 implementation-related 数据(一个 pimpl)创建了一个私有的 class,将旧数据和我的新数据都放在那里,因为现有名称似乎合适我保留了名称。
在同一天晚些时候的一次简短会议后,我将它从 data 缩写为 d,我们一致认为我 发明 偶然发现的模式很好,我们应该使用它被广泛使用,并且 d->
足够短且足够独特,可以在任何地方用作 implementation-specific 字段的标记。
在同一次会议上,我们决定从那时起将 implementation-specific 数据作为一项政策放在 d-> 中,主要是为了减少包含的数量,同时也保持声明API 总体来说很干净。 class 声明中的私有变量越少,意味着出错的机会越少、诱惑越少、与 subclass 命名冲突的东西越少等等。更好的卫生。