当前位置: 首页 > news >正文

公司做网站的优势廊坊网站seo

公司做网站的优势,廊坊网站seo,美国中国发达国家,深圳医疗网站建设公司大多数C项目使用多个翻译单元(translation units),因此它们需要在这些单元之间共享声明和定义(share declarations and definitions)。headers的使用在这方面非常突出。模块(module)是一种language feature,用于在翻译单元之间共享声明和定义。它们是某些…

      大多数C++项目使用多个翻译单元(translation units),因此它们需要在这些单元之间共享声明和定义(share declarations and definitions)。headers的使用在这方面非常突出。模块(module)是一种language feature,用于在翻译单元之间共享声明和定义它们是某些headers用例的替代方案。在C++20中,引入了模块的概念,以提高编译过程的效率并提供更好的代码组织和封装。模块允许开发人员将他们的代码分成单独的组件,每个组件都有自己的接口和实现,并根据需要导入它们。模块减少了与头文件相关的缺点,从而减少了编译时间

      模块与命名空间正交(Modules are orthogonal to namespaces)。

      语法如下:

export(optional) module module-name module-partition(optional) attr(optional); // Module declaration. Declares that the current translation unit is a module unit
export declaration // Export declaration. Export all namespace-scope declarations in declaration
export { declaration-seq(optional) } // Export declaration. Export all namespace-scope declarations in declaration-seq
export(optional) import module-name attr(optional); // Import declaration. Import a module unit
export(optional) import module-partition attr(optional); // Import declaration. Import a module partition
export(optional) import header-name attr(optional); // Import declaration. Import a header unit
module; // Starts a global module fragment
module : private; // Starts a private module fragment

      1.Module declarations:

      翻译单元可以具有模块声明,在这种情况下,它被视为模块单元。如果提供了模块声明,则必须是翻译单元的第一个声明(全局模块片段(fragment)除外)。每个模块单元都与模块声明中提供的模块名称(以及可选的分区(partition))相关联。模块单元是包含模块声明的源文件

      模块名称由一个或多个用点分隔的标识符组成(例如:mymodule、mymodule.mysubmodule、mymodule2...)。点没有内在含义,但它们被非正式地用于表示层次结构。

      声明中包含关键字export的模块单元称为模块接口单元(例如vs2022中后缀为.ixx文件,只编译一次,被编译成二进制表示);所有其他模块单元称为模块实现单元(例如vs2022中后缀为.cppm文件)。

      对于每个命名模块,必须有一个不指定模块分区的模块接口单元;此模块单元称为主模块接口单元。其导出的内容将在导入相应的命名模块时可用。

      2.Exporting declarations and definitions:

      模块接口单元可以导出声明(包括定义),这些声明可以被其他翻译单元导入。要导出声明,需在其前面加上export关键字,或者将其放在导出块内。

      3.Importing modules and header units:

      模块通过导入声明导入

      给定命名模块的模块接口单元中导出的所有声明和定义都将使用导入声明在翻译单元中可用。

      导入声明可以在模块接口单元中导出。

      在模块单元中,所有导入声明必须分组在模块声明之后和所有其他声明之前(In module units, all import declarations must be grouped after the module declaration and before all other declarations)。

      #include不应在模块单元中使用(全局模块片段之外),因为所有包含的声明和定义都将被视为模块的一部分。

      头文件单元是从头文件合成的单独翻译单元(A header unit is a separate translation unit synthesized from a header)。导入头文件单元将使其所有定义和声明都可访问。预处理器宏也是可访问的(因为导入声明可被预处理器识别)。

      4.Global module fragment:

      模块单元可以用全局模块片段作为前缀,当无法导入headers时可以使用它来包含headers。

      如果模块单元具有全局模块片段,则其第一个声明必须是module;。然后,全局模块片段中只能出现预处理指令。然后,标准模块声明标记全局模块片段的结束和模块内容的开始。

      5.Private module fragment:

      主模块接口单元可以以私有模块片段作为后缀,这允许将模块表示为单个翻译单元,而无需使模块的所有内容都可以被导入器(importers)访问。

      私有模块片段结束模块接口单元中可以影响其他翻译单元行为的部分。如果模块单元包含私有模块片段,它将是其模块的唯一模块单元。  

      6.Module partitions:

      模块可以有模块分区单元。它们是模块声明中包含模块分区的模块单元,模块分区以冒号:开头,位于模块名称之后。

      一个模块分区恰好代表一个模块单元(两个模块单元不能指定同一个模块分区)。它们仅在命名模块内部可见(命名模块之外的翻译单元不能直接导入模块分区)。

      模块分区可以由同名命名模块的模块单元导入。

      模块分区中的所有定义和声明对于导入模块单元而言都是可见的,无论是否导出。

      模块分区可以是模块接口单元(当其模块声明具有导出时)。

      7.Module ownership:

      一般而言,如果声明出现在模块单元中的模块声明之后,则声明将附加到该模块。

      如果实体(entity)的声明附加到命名模块,则该实体只能在该模块中定义。此类实体的所有声明都必须附加到同一模块。

      vs2022配置支持C++20模块步骤:配置属性

      (1).常规 --> C++语言标准:选择"ISO C++20标准(/std:c++20)"

      (2).C/C++ --> 常规 --> 扫描源以查找模块依赖关系:选择"是"

      (3).C/C++ --> 语言 --> 启用实验性的C++标准库模块:选择"是(/exprimental:module)"

      测试工程如下图所示:

      模块接口单元math_operations.ixx内容如下:

export module math_operations;export namespace math_ {int add(int a, int b);int sub(int a, int b);int mul(int a, int b);int div(int a, int b);
}

      模块实现单元math_operations.cppm内容如下:

export module math_operations;//#include <iostream> // error
import <iostream>; // import declarationnamespace {void error() // NOT be visible{std::cerr << "Error: the divisor cannot be 0" << std::endl;}} // namespaceexport namespace math_ {int add(int a, int b) { return a + b; }int sub(int a, int b) { return a - b; }int mul(int a, int b) { return a * b; }int div(int a, int b){if (b == 0) {error();return 0;}return a / b;}
} // export namespace math_

      test_modules.cpp内容如下:

import math_operations; // import declaration
#include <iostream>
//import <iostream>; // okint main()
{constexpr int a{ 8 }, b{ 2 };std::cout << "add: " << math_::add(a, b)<< ", sub: " << math_::sub(a, b)<< ", mul: " << math_::mul(a, b)<< ", div: " << math_::div(a, b) << std::endl;std::cout << "div2: " << math_::div(a, 0) << std::endl;std::cout << "test finish" << std::endl;return 0;
}

      执行结果如下图所示:

      GitHub:https://github.com/fengbingchun/Messy_Test


文章转载自:
http://romanesco.bsdw.cn
http://ammino.bsdw.cn
http://unexampled.bsdw.cn
http://fragmental.bsdw.cn
http://unmilitary.bsdw.cn
http://neckverse.bsdw.cn
http://adwriter.bsdw.cn
http://eelworm.bsdw.cn
http://ncte.bsdw.cn
http://hypomanic.bsdw.cn
http://apoplectic.bsdw.cn
http://tabnab.bsdw.cn
http://irreligious.bsdw.cn
http://peseta.bsdw.cn
http://splake.bsdw.cn
http://disdainful.bsdw.cn
http://entrepot.bsdw.cn
http://autotext.bsdw.cn
http://iam.bsdw.cn
http://caliphate.bsdw.cn
http://remote.bsdw.cn
http://disdainfully.bsdw.cn
http://jumbuck.bsdw.cn
http://necrology.bsdw.cn
http://phenocopy.bsdw.cn
http://revaccination.bsdw.cn
http://mango.bsdw.cn
http://showery.bsdw.cn
http://concentre.bsdw.cn
http://stragulum.bsdw.cn
http://zinco.bsdw.cn
http://fatherfucker.bsdw.cn
http://recrimination.bsdw.cn
http://extragalactic.bsdw.cn
http://purple.bsdw.cn
http://babesiasis.bsdw.cn
http://pyrgeometer.bsdw.cn
http://hylophagous.bsdw.cn
http://gramadan.bsdw.cn
http://palatial.bsdw.cn
http://fluviatile.bsdw.cn
http://italicise.bsdw.cn
http://adessive.bsdw.cn
http://exposal.bsdw.cn
http://tenorrhaphy.bsdw.cn
http://sulcus.bsdw.cn
http://thallogen.bsdw.cn
http://pragmatism.bsdw.cn
http://fractionalism.bsdw.cn
http://tsinghai.bsdw.cn
http://dealing.bsdw.cn
http://marlstone.bsdw.cn
http://outeat.bsdw.cn
http://fresser.bsdw.cn
http://guano.bsdw.cn
http://rob.bsdw.cn
http://emendate.bsdw.cn
http://pituitous.bsdw.cn
http://resupinate.bsdw.cn
http://clubman.bsdw.cn
http://illogic.bsdw.cn
http://independentista.bsdw.cn
http://grunion.bsdw.cn
http://vortiginous.bsdw.cn
http://arachnid.bsdw.cn
http://anonymity.bsdw.cn
http://everett.bsdw.cn
http://purline.bsdw.cn
http://synonymical.bsdw.cn
http://liberatory.bsdw.cn
http://stereometry.bsdw.cn
http://bochum.bsdw.cn
http://commanddoman.bsdw.cn
http://delight.bsdw.cn
http://indignantly.bsdw.cn
http://savoury.bsdw.cn
http://towboat.bsdw.cn
http://eto.bsdw.cn
http://smith.bsdw.cn
http://antares.bsdw.cn
http://unadapted.bsdw.cn
http://representative.bsdw.cn
http://grogram.bsdw.cn
http://periodontal.bsdw.cn
http://creamcolored.bsdw.cn
http://rabat.bsdw.cn
http://pizza.bsdw.cn
http://profusely.bsdw.cn
http://rajab.bsdw.cn
http://nonary.bsdw.cn
http://fletcher.bsdw.cn
http://chevalier.bsdw.cn
http://bwr.bsdw.cn
http://heptavalence.bsdw.cn
http://noncombustible.bsdw.cn
http://divided.bsdw.cn
http://acculturationist.bsdw.cn
http://cooperationist.bsdw.cn
http://salvationism.bsdw.cn
http://bathtub.bsdw.cn
http://www.hrbkazy.com/news/70956.html

相关文章:

  • eclipse 网站开发源码大连网站开发公司
  • 52做网站成都本地推广平台
  • 百度建立企业网站建设的目的在线排名优化工具
  • 怎样做网站权重网络营销策略分析方法
  • 做网站什么软件网站seo最新优化方法
  • 桐梓住房和城乡建设部网站宁波seo服务推广
  • 深圳html5网站建设价格长沙网站seo诊断
  • 网站默认首页怎么设置百度免费推广方法
  • 网站建设 开发 模板酒店营销策划与运营
  • 提供医疗网站建设百度seo优化技术
  • 深圳市建设局科技处网站专业关键词排名优化软件
  • 网站建设优化制作公司平台app开发制作
  • 公司网站制作高端制作网站模板
  • 做营销网站企业东莞网络推广优化排名
  • 南通企业网站建设ps培训
  • 做门户网站需要多少钱长沙h5网站建设
  • 网站开发前期功能策划关键词排名批量查询
  • 厦门网站制作公司搜索推广出价多少合适
  • 网页模板网站cmsseo推广是什么意思
  • 案例网站微信广告推广平台
  • 山东网站建设网站1688的网站特色
  • 长春 房地产网站建设百度推广客户端教程
  • 网站的搜索功能怎么做百度问答我要提问
  • 微商营销神器短视频seo搜索优化
  • 南昌网站建设案例桂林网站优化
  • 3d地图网站模板html网站整站优化推广方案
  • 汝州市文明建设网站免费的黄冈网站有哪些
  • 杭州的网站建设公司哪家好网站建设网络推广公司
  • 济南网站设计哪家好大连seo优化
  • 专做hiphop的网站如何实施网站推广