- 1、本文档共17页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Qt源码中的Template模板用法
* Qt源码中的C++ Template 用法 yoyo,2015 Review of C++ Template Syntax Qt Template MetaProgramming C++ Template usage in Qt 1 2 3 一般用法 Review of C++ Template Syntaxyntax // 一个简单的加法模板 templateclass T class Addition { public: T fun( T a, T b ) { return ( a + b ); } }; specialization Review of C++ Template Syntaxyntax template class Additionchar * { public: char * fun( char * a, char * b ) { ... strcat_s(... ); return a; } }; Partial specialization Review of C++ Template Syntaxyntax /* ** 特化为引用,指针类型 ** 偏特化,半特化,局部特化,部分特化 ** 在编码时,总纠结着是指针好呢,还是引用好呢,要加const? ** 有了这样的特化,确实方便甚多。 */ templateclass T class AdditionT { public: T fun( T a, T b ) { a = a + b; return a; } }; 编译期类型推断 Qt Templatetax /* quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e. sizeof(void *) == sizeof(quintptr) sizeof(void *) == sizeof(qptrdiff) */ template int struct QIntegerForSize; template struct QIntegerForSize1 { typedef quint8 Unsigned; typedef qint8 Signed; }; template struct QIntegerForSize2 { typedef quint16 Unsigned; typedef qint16 Signed; }; template struct QIntegerForSize4 { typedef quint32 Unsigned; typedef qint32 Signed; }; template struct QIntegerForSize8 { typedef quint64 Unsigned; typedef qint64 Signed; }; template class T struct QIntegerForSizeof : QIntegerForSizesizeof(T) { }; typedef QIntegerForSizeofvoid*::Unsigned quintptr; typedef QIntegerForSizeofvoid*::Signed qptrdiff; QT Assistant 的文档 Qt Templatetax typedef quintptr Integral type for representing a pointers (useful for hashing, etc.). Typedef for either quint32 or quint64. This type is guaranteed to be the same size as a pointer on all platforms supported by Qt. On a system with 32-bit pointers, quintptr is a typedef for quint32; on a system with 64-bit pointers, quintptr is a typedef for quint64. Note that quintptr is unsigned. Use qptrdiff for sig
您可能关注的文档
- miui主题笔记.doc
- midtermtest复习计算题tostudent.docx
- MentalRay室内夜景渲染教程.doc
- Module1DeepSouthIntroductionandReadingPractice课件(外研版选修8).ppt
- Module5ALessoninaLab课件.ppt
- moldflowcae教程Lesson10.ppt
- MPLS笔记.doc
- 现代波利亚表MicrosoftWord文档.doc
- MSF的接收和发送数据流程韩婷.doc
- MOL集装箱检验标准.doc
- 2024-2030年中国充电型电蚊拍行业供需分析及发展前景研究报告.docx
- 2024-2030年中国光伏制氢行业经营现状分析与可持续发展规划研究报告.docx
- 2024-2030年中国光伏发电行业趋势洞察及未来应用领域规模研究研究报告.docx
- 2024-2030年中国光催化纳米涂料行业产能预测及发展战略研究报告.docx
- 2024-2030年中国光刻机行业竞争格局及未来销售规模调研研究报告.docx
- 2024-2030年中国儿童游乐场设备行业市场发展趋势与前景展望战略分析报告.docx
- 2024-2030年中国光网络终端(ONT)行业供需平衡状况与未来行情走势报告.docx
- 2024-2030年中国光纤连接器市场竞争策略及投资潜力风险预警报告.docx
- 2024-2030年中国催化剂行业深度调研及投资前景预测研究报告.docx
- 2024-2030年中国克拉霉素分散片行业市场现状供需分析及投资评估规划分析研究报告.docx
文档评论(0)