• 首页
  • 期刊简介
  • 编委会
  • 投稿指南
  • 收录情况
  • 杂志订阅
  • 联系我们
引用本文:闵 军,罗 泓.基于C++17的泛型函数容器实现方法研究[J].软件工程,2019,22(5):18-24.【点击复制】
【打印本页】   【下载PDF全文】   【查看/发表评论】  【下载PDF阅读器】  
←前一篇|后一篇→ 过刊浏览
分享到: 微信 更多
基于C++17的泛型函数容器实现方法研究
闵 军,罗 泓1,2
1.(1.宜宾学院图书馆,四川 宜宾 644000;2.
2.宜宾学院文学与新闻传媒学院,四川 宜宾 644000)
摘 要: 泛型函数容器的使用可以解耦对象之间的调用关系,有利于实现高内聚、低耦合的软件设计原则。C++ 标准库中并没有这样的容器,用C++旧标准实现也很困难、很低效。C++1x等新标准发布后,出现了一些更好的实现 方式。本文将在已有设计的基础之上,基于C++17新标准,利用if constexpr、fold expression、std::invoke等新技 术,提供一种泛型函数容器的实现方式。测试表明该实现方式简洁高效,解决了重载函数和某些特殊函数的注册调用问 题,可以显著降低耦合性、提高代码复用性。
关键词: C++17;泛型;函数容器;高内聚;低耦合
中图分类号: TP311.1    文献标识码: A
Study on the Implementation of Generic Function Container Based on C++17
MIN Jun,LUO Hong1,2
1.( 1.Library, Yibin University, Yibin 644000, China;2.
2.College of Literature and Journalism, Yibin University, Yibin 644000, China)
Abstract: The application of generic function containers can decouple the calling relationships between objects,conducive to the realization of high cohesion and low coupling software design principles.There is no such container in the C++ standard library,and it is very difficult and inefficient to implement with the old C++ standard.The release of new standards,such as C++1x,has brought some better implementation methods.This paper provides a generic function container implementation method based on the existing design and the new C++17 standard,via some new technologies such as if constexpr,fold expression,and std::invoke.Test results show that the simple and efficient implementation method effectively solves the problem of registration and calling of overloaded functions and some special functions,significantly reducing coupling and improving code reusability
Keywords: C++17;generic;function container;high aggregation;low coupling


版权所有:软件工程杂志社
地址:辽宁省沈阳市浑南区新秀街2号 邮政编码:110179
电话:0411-84767887 传真:0411-84835089 Email:semagazine@neusoft.edu.cn
备案号:辽ICP备17007376号-1
技术支持:北京勤云科技发展有限公司

用微信扫一扫

用微信扫一扫