{"id":5916,"date":"2020-05-29T07:22:14","date_gmt":"2020-05-29T07:22:14","guid":{"rendered":"https:\/\/www.modernescpp.com\/index.php\/c-20-divide-modules\/"},"modified":"2023-09-28T06:46:24","modified_gmt":"2023-09-28T06:46:24","slug":"c-20-divide-modules","status":"publish","type":"post","link":"https:\/\/www.modernescpp.com\/index.php\/c-20-divide-modules\/","title":{"rendered":"C++20: Structure Modules"},"content":{"rendered":"<p>When your module becomes bigger, you want to divide its functionality into manageable components. C++20 modules offer two approaches: submodules and partitions. Let me discuss both approaches in this post.<\/p>\n<p><!--more--><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-8397 size-full\" style=\"display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/09\/TimelineCpp20Modules.png\" alt=\"\" width=\"1081\" height=\"399\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/09\/TimelineCpp20Modules.png 1081w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/09\/TimelineCpp20Modules-300x111.png 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/09\/TimelineCpp20Modules-1030x380.png 1030w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/09\/TimelineCpp20Modules-768x283.png 768w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2021\/09\/TimelineCpp20Modules-705x260.png 705w\" sizes=\"auto, (max-width: 1081px) 100vw, 1081px\" \/><\/p>\n<p>Before I start, I want to make a short disclaimer. For simplicity reasons, I ignore, in this post, the separation of the module interface unit and the module implementation unit. This means I define each module in one file. Additionally, I don&#8217;t use namespaces. I described both features, which you should use, in my previous post, &#8220;<a href=\"https:\/\/bit.ly\/ModuleInterfaceUnitModuleImplementationUnit\">C++20: Module Interface Unit and Module Implementation Unit<\/a>&#8220;.<\/p>\n<p>The idea of a submodule is straightforward. Consequently, I start with them.<\/p>\n<h2>Submodules<\/h2>\n<p>A module can import modules and then re-export them.<\/p>\n<p>The module <span style=\"font-family: courier new, courier;\">math<\/span>\u00a0imports in the following example the submodules <span style=\"font-family: courier new, courier;\">math.math1<\/span> and <span style=\"font-family: courier new, courier;\">math.math2<\/span>.<\/p>\n<ul>\n<li>Module <span style=\"font-family: courier new, courier;\">math<\/span><\/li>\n<\/ul>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ mathModule.ixx<\/span>\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> module math;\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> import math.math1;\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> import math.math2;\n<\/pre>\n<\/div>\n<p>The expression <span style=\"font-family: courier new, courier;\">export import math.math1<\/span> imports the module <span style=\"font-family: courier new, courier;\">math.math<\/span>1 and re-exports it as part of the module\u00a0\u00a0<span style=\"font-family: courier new, courier;\">math<\/span>.<\/p>\n<p>For completeness, here are the <span style=\"font-family: courier new, courier;\">math.math1<\/span> and <span style=\"font-family: courier new, courier;\">math.math2. <\/span>I used a point to separate the module <span style=\"font-family: courier new, courier;\">math<\/span> from its submodules. This point is not necessary.<\/p>\n<ul>\n<li>Submodule<span style=\"font-family: courier new, courier;\"> math.math1<\/span><\/li>\n<\/ul>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ mathModule1.ixx<\/span>\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> module math.math1;          <span style=\"color: #0099ff; font-style: italic;\">\/\/ (1)   <\/span>\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> <span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">add<\/span>(<span style=\"color: #007788; font-weight: bold;\">int<\/span> fir, <span style=\"color: #007788; font-weight: bold;\">int<\/span> sec) { <span style=\"color: #0099ff; font-style: italic;\">\/\/ (2)<\/span>\n    <span style=\"color: #006699; font-weight: bold;\">return<\/span> fir <span style=\"color: #555555;\">+<\/span> sec;\n}\n<\/pre>\n<\/div>\n<ul>\n<li>Submodule <span style=\"font-family: courier new, courier;\">math.math2<\/span><\/li>\n<\/ul>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ mathModule2.ixx<\/span>\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> module math.math2;     <span style=\"color: #0099ff; font-style: italic;\">\/\/ (1)   <\/span>\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> {                      <span style=\"color: #0099ff; font-style: italic;\">\/\/ (2)<\/span>\n    <span style=\"color: #007788; font-weight: bold;\">int<\/span> mul(<span style=\"color: #007788; font-weight: bold;\">int<\/span> fir, <span style=\"color: #007788; font-weight: bold;\">int<\/span> sec) {\n        <span style=\"color: #006699; font-weight: bold;\">return<\/span> fir <span style=\"color: #555555;\">*<\/span> sec;\n    }\n}\n<\/pre>\n<\/div>\n<p>If you look carefully, you recognize a slight difference in the export statements (2) in the modules <span style=\"font-family: courier new, courier;\">math.math1<\/span> and<span style=\"font-family: courier new, courier;\"> math.math2<\/span>. <span style=\"font-family: courier new, courier;\">math.math1<\/span> uses an export specifier and <span style=\"font-family: courier new, courier;\">math.math2<\/span> as a so-called export group or export block.<\/p>\n<p>From the client&#8217;s perspective, using the <span style=\"font-family: courier new, courier;\">math<\/span> module is straightforward.<\/p>\n<ul>\n<li>Client program<\/li>\n<\/ul>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ mathModuleClient.cpp<\/span>\n\nimport std.core;\nimport math;\n\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">main<\/span>() {\n\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> std<span style=\"color: #555555;\">::<\/span>endl;\n\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">\"add(3, 4): \"<\/span> <span style=\"color: #555555;\">&lt;&lt;<\/span> add(<span style=\"color: #ff6600;\">3<\/span>, <span style=\"color: #ff6600;\">4<\/span>) <span style=\"color: #555555;\">&lt;&lt;<\/span> std<span style=\"color: #555555;\">::<\/span>endl;\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">\"mul(3, 4): \"<\/span> <span style=\"color: #555555;\">&lt;&lt;<\/span> mul(<span style=\"color: #ff6600;\">3<\/span>, <span style=\"color: #ff6600;\">4<\/span>) <span style=\"color: #555555;\">&lt;&lt;<\/span> std<span style=\"color: #555555;\">::<\/span>endl;\n    \n}\n<\/pre>\n<\/div>\n<p>Compiling, linking, and executing the program works as expected with the Microsoft implementation of modules:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\">cl.exe <span style=\"color: #555555;\">\/<\/span>std<span style=\"color: #555555;\">:<\/span>c<span style=\"color: #555555;\">++<\/span>latest <span style=\"color: #555555;\">\/<\/span>c <span style=\"color: #555555;\">\/<\/span>experimental<span style=\"color: #555555;\">:<\/span>module mathModule1.ixx <span style=\"color: #555555;\">\/<\/span>EHsc <span style=\"color: #555555;\">\/<\/span>MD  <span style=\"color: #0099ff; font-style: italic;\">\/\/ (3)<\/span>\ncl.exe <span style=\"color: #555555;\">\/<\/span>std<span style=\"color: #555555;\">:<\/span>c<span style=\"color: #555555;\">++<\/span>latest <span style=\"color: #555555;\">\/<\/span>c <span style=\"color: #555555;\">\/<\/span>experimental<span style=\"color: #555555;\">:<\/span>module mathModule2.ixx <span style=\"color: #555555;\">\/<\/span>EHsc <span style=\"color: #555555;\">\/<\/span>MD  <span style=\"color: #0099ff; font-style: italic;\">\/\/ (3)<\/span>\ncl.exe <span style=\"color: #555555;\">\/<\/span>std<span style=\"color: #555555;\">:<\/span>c<span style=\"color: #555555;\">++<\/span>latest <span style=\"color: #555555;\">\/<\/span>c <span style=\"color: #555555;\">\/<\/span>experimental<span style=\"color: #555555;\">:<\/span>module mathModule.ixx <span style=\"color: #555555;\">\/<\/span>EHsc <span style=\"color: #555555;\">\/<\/span>MD   <span style=\"color: #0099ff; font-style: italic;\">\/\/ (3)<\/span>\ncl.exe <span style=\"color: #555555;\">\/<\/span>std<span style=\"color: #555555;\">:<\/span>c<span style=\"color: #555555;\">++<\/span>latest <span style=\"color: #555555;\">\/<\/span>experimental<span style=\"color: #555555;\">:<\/span>module mathModuleClient.cpp mathModule1.obj mathModule2.obj mathModule.obj <span style=\"color: #555555;\">\/<\/span>EHsc <span style=\"color: #555555;\">\/<\/span>MD <span style=\"color: #0099ff; font-style: italic;\">\/\/ (4)<\/span>\n<\/pre>\n<\/div>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-5914\" style=\"display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClientFix.png\" alt=\"mathModuleClientFix\" width=\"350\" height=\"147\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClientFix.png 1221w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClientFix-300x126.png 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClientFix-1024x430.png 1024w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClientFix-768x323.png 768w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/p>\n<p>Each compilation process (3) produces two artifacts: The IFC file (interface file ) <span style=\"font-family: courier new, courier;\">*.ifc,<\/span> which is implicitly used in (4), and the\u00a0<span style=\"font-family: courier new, courier;\"> *.obj<\/span> file, which is explicitly used in (4).<\/p>\n<p>I already mentioned that a submodule is just a module. Each submodule has a module declaration (1). Consequently, I can create a second client only interested in <span style=\"font-family: courier new, courier;\">math.math1<\/span> module.<\/p>\n<ul>\n<li>\u00a0Second client program<\/li>\n<\/ul>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ mathModuleClient1.cpp<\/span>\n\nimport std.core;\nimport math.math1;\n\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">main<\/span>() {\n\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> std<span style=\"color: #555555;\">::<\/span>endl;\n\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">\"add(3, 4): \"<\/span> <span style=\"color: #555555;\">&lt;&lt;<\/span> add(<span style=\"color: #ff6600;\">3<\/span>, <span style=\"color: #ff6600;\">4<\/span>) <span style=\"color: #555555;\">&lt;&lt;<\/span> std<span style=\"color: #555555;\">::<\/span>endl;\n    \n}\n<\/pre>\n<\/div>\n<p>It&#8217;s sufficient to compile the new client program and link it. The existing module <span style=\"font-family: courier new, courier;\">math.math1<\/span> works fine.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\">cl.exe <span style=\"color: #555555;\">\/<\/span>std<span style=\"color: #555555;\">:<\/span>c<span style=\"color: #555555;\">++<\/span>latest <span style=\"color: #555555;\">\/<\/span>experimental<span style=\"color: #555555;\">:<\/span>module mathModuleClient1.cpp mathModule1.obj  <span style=\"color: #555555;\">\/<\/span>EHsc <span style=\"color: #555555;\">\/<\/span>MD\n<\/pre>\n<\/div>\n<h2><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-5915\" style=\"display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClient1Fix.png\" alt=\"mathModuleClient1Fix\" width=\"350\" height=\"117\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClient1Fix.png 1310w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClient1Fix-300x101.png 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClient1Fix-1024x343.png 1024w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClient1Fix-768x257.png 768w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/h2>\n<p>The division of modules into modules and submodules is a means for the module designer to give the user of the module the possibility to import more granular parts of the module. This observation does not apply to module partitions.<\/p>\n<h2>Module Partitions<\/h2>\n<p>A module can be divided into partitions. Each partition consists of a module interface unit (partition interface file) and zero or more module implementation units (see &#8220;<a href=\"https:\/\/bit.ly\/ModuleInterfaceUnitModuleImplementationUnit\">C++20: Module Interface Unit and Module Implementation Unit<\/a>&#8220;). The names the partitions export are imported and re-exported by the primary module interface unit (primary interface file). The name of a partition must begin with the name of the module. The partitions can not exist on their own.<\/p>\n<p>The description of module partitions is more challenging to understand than its implementation. In the following lines, I rewrite the <span style=\"font-family: courier new, courier;\">math<\/span> module and its submodules <span style=\"font-family: courier new, courier;\">math.math1<\/span> and <span style=\"font-family: courier new, courier;\">math.math2<\/span> to module partitions. In this straightforward process, I refer to the shortly introduced terms of module partitions.<\/p>\n<ul>\n<li>\u00a0Primary interface file <span style=\"font-family: courier new, courier;\">mathPartition.ixx<\/span><\/li>\n<\/ul>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ mathPartition.ixx<\/span>\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> module math;   <span style=\"color: #0099ff; font-style: italic;\">\/\/ (1)<\/span>\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> import <span style=\"color: #555555;\">:<\/span>math1; <span style=\"color: #0099ff; font-style: italic;\">\/\/ (2)<\/span>\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> import <span style=\"color: #555555;\">:<\/span>math2; <span style=\"color: #0099ff; font-style: italic;\">\/\/ (2)<\/span>\n<\/pre>\n<\/div>\n<p>The primary interface file consists of the module declaration (1). It imports and re-exports the partitions <span style=\"font-family: courier new, courier;\">math1<\/span> and <span style=\"font-family: courier new, courier;\">math2<\/span> using colons (2). The name of the partitions must begin with the name of the module. Consequently, you don&#8217;t have to specify them.<\/p>\n<ul>\n<li>Module partitions (<span style=\"font-family: courier new, courier;\">mathPartition1.ixx<\/span>, and <span style=\"font-family: courier new, courier;\">mathPartition2.ixx<\/span>)<\/li>\n<\/ul>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ mathPartition1.ixx<\/span>\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> module math<span style=\"color: #555555;\">:<\/span>math1;     <span style=\"color: #0099ff; font-style: italic;\">\/\/ (1)   <\/span>\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> <span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">add<\/span>(<span style=\"color: #007788; font-weight: bold;\">int<\/span> fir, <span style=\"color: #007788; font-weight: bold;\">int<\/span> sec) {\n    <span style=\"color: #006699; font-weight: bold;\">return<\/span> fir <span style=\"color: #555555;\">+<\/span> sec;\n}\n<\/pre>\n<\/div>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ mathPartition2.ixx<\/span>\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> module math<span style=\"color: #555555;\">:<\/span>math2;     <span style=\"color: #0099ff; font-style: italic;\">\/\/ (1)   <\/span>\n\n<span style=\"color: #006699; font-weight: bold;\">export<\/span> { \n    <span style=\"color: #007788; font-weight: bold;\">int<\/span> mul(<span style=\"color: #007788; font-weight: bold;\">int<\/span> fir, <span style=\"color: #007788; font-weight: bold;\">int<\/span> sec) {\n        <span style=\"color: #006699; font-weight: bold;\">return<\/span> fir <span style=\"color: #555555;\">*<\/span> sec;\n    }\n}\n<\/pre>\n<\/div>\n<p>Like the module declaration, (1) declares a module interface partition. A module interface partition is also a module interface unit. The name <span style=\"font-family: courier new, courier;\">math<\/span> stands for the module and <span style=\"font-family: courier new, courier;\">math1<\/span> or <span style=\"font-family: courier new, courier;\">math2<\/span> for the partition.<\/p>\n<ul>\n<li>Client program<\/li>\n<\/ul>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0099ff; font-style: italic;\">\/\/ mathModuleClient.cpp<\/span>\n\nimport std.core;\nimport math;\n\n<span style=\"color: #007788; font-weight: bold;\">int<\/span> <span style=\"color: #cc00ff;\">main<\/span>() {\n\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> std<span style=\"color: #555555;\">::<\/span>endl;\n\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">\"add(3, 4): \"<\/span> <span style=\"color: #555555;\">&lt;&lt;<\/span> add(<span style=\"color: #ff6600;\">3<\/span>, <span style=\"color: #ff6600;\">4<\/span>) <span style=\"color: #555555;\">&lt;&lt;<\/span> std<span style=\"color: #555555;\">::<\/span>endl;\n    std<span style=\"color: #555555;\">::<\/span>cout <span style=\"color: #555555;\">&lt;&lt;<\/span> <span style=\"color: #cc3300;\">\"mul(3, 4): \"<\/span> <span style=\"color: #555555;\">&lt;&lt;<\/span> mul(<span style=\"color: #ff6600;\">3<\/span>, <span style=\"color: #ff6600;\">4<\/span>) <span style=\"color: #555555;\">&lt;&lt;<\/span> std<span style=\"color: #555555;\">::<\/span>endl;\n    \n}\n<\/pre>\n<\/div>\n<p>You may have already assumed it: the client program is identical to the one I previously used with submodules. The same observation holds for the creation of the executable.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #f0f3f3; overflow: auto; width: auto; gray;border-width: .1em .1em .1em .8em;\">\n<pre style=\"margin: 0; line-height: 125%;\">cl.exe <span style=\"color: #555555;\">\/<\/span>std<span style=\"color: #555555;\">:<\/span>c<span style=\"color: #555555;\">++<\/span>latest <span style=\"color: #555555;\">\/<\/span>c <span style=\"color: #555555;\">\/<\/span>experimental<span style=\"color: #555555;\">:<\/span>module mathPartition1.ixx <span style=\"color: #555555;\">\/<\/span>EHsc <span style=\"color: #555555;\">\/<\/span>MD\ncl.exe <span style=\"color: #555555;\">\/<\/span>std<span style=\"color: #555555;\">:<\/span>c<span style=\"color: #555555;\">++<\/span>latest <span style=\"color: #555555;\">\/<\/span>c <span style=\"color: #555555;\">\/<\/span>experimental<span style=\"color: #555555;\">:<\/span>module mathPartition2.ixx <span style=\"color: #555555;\">\/<\/span>EHsc <span style=\"color: #555555;\">\/<\/span>MD\ncl.exe <span style=\"color: #555555;\">\/<\/span>std<span style=\"color: #555555;\">:<\/span>c<span style=\"color: #555555;\">++<\/span>latest <span style=\"color: #555555;\">\/<\/span>c <span style=\"color: #555555;\">\/<\/span>experimental<span style=\"color: #555555;\">:<\/span>module mathPartition.ixx <span style=\"color: #555555;\">\/<\/span>EHsc <span style=\"color: #555555;\">\/<\/span>MD\ncl.exe <span style=\"color: #555555;\">\/<\/span>std<span style=\"color: #555555;\">:<\/span>c<span style=\"color: #555555;\">++<\/span>latest <span style=\"color: #555555;\">\/<\/span>experimental<span style=\"color: #555555;\">:<\/span>module mathModuleClient.cpp mathPartition1.obj mathPartition2.obj mathPartition.obj <span style=\"color: #555555;\">\/<\/span>EHsc <span style=\"color: #555555;\">\/<\/span>MD\n<\/pre>\n<\/div>\n<h2><img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-5914\" style=\"display: block; margin-left: auto; margin-right: auto;\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClientFix.png\" alt=\"mathModuleClientFix\" width=\"350\" height=\"147\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClientFix.png 1221w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClientFix-300x126.png 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClientFix-1024x430.png 1024w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2020\/05\/mathModuleClientFix-768x323.png 768w\" sizes=\"auto, (max-width: 350px) 100vw, 350px\" \/><\/h2>\n<h2>What&#8217;s next?<\/h2>\n<p>There are more modules in C++20. For example, modules introduce header units, and they distinguish between global and private module fragments. Finally, I want to write about linkage.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When your module becomes bigger, you want to divide its functionality into manageable components. C++20 modules offer two approaches: submodules and partitions. Let me discuss both approaches in this post.<\/p>\n","protected":false},"author":21,"featured_media":8397,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[375],"tags":[443],"class_list":["post-5916","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-20","tag-modules"],"_links":{"self":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/5916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/comments?post=5916"}],"version-history":[{"count":2,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/5916\/revisions"}],"predecessor-version":[{"id":8400,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/5916\/revisions\/8400"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media\/8397"}],"wp:attachment":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media?parent=5916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/categories?post=5916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/tags?post=5916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}