Search⌘ K
AI Features

Guidelines for a Module Structure

Explore the principles of structuring C++20 modules effectively. Understand how to use the global module fragment, organize headers, handle module purview, and manage imports and exports for better compilation and code clarity.

We'll cover the following...

Let’s examine guidelines for how to structure a module.

C++
module; // global module fragment
#include <headers for libraries not modularized so far>
export module math; // module declaration; starts the module purview
import <importing of other modules>
<non-exported declarations> // names only visibile inside the module
export namespace math {
<exported declarations> // exported names
}

This guideline serves one purpose: give you a simplified structure of a module and an idea of what I’m going to write about. So, what’s new in this module structure?

  • The global module ...