2 ms·
Presumably you're expected to act like Ada and put the interface in a separate TU that can be processed first by the build system.
by kevin_thibedeau 5y ago
Presumably you're expected to act like Ada and put the interface in a separate TU that can be processed first by the build system.
- dgellow 5y agoEdit: I just notice now that you said "TU", my mind autocompleted your sentence with "file" instead the first time I read it. Still keeping my comment here, module :private is not well known and a nice way to declare a distinct interface Translation Unit while keeping everything in one file. You can do this, but you can also use the "module :private" fragment if you want to have everything in one file while still keeping the distinction between interface and implementation. Example: // File "mymodule.ixx" module; #include <string> // declare interface export module mymodule; export namespace mymodule { // templates have to be declared // in interface to be known at // compile-time template<typename T> T add(T x, T y) { return x + y; } std::string greetings(); } // implement interface module :private; std::string mymodule::greetings() { return "hello"; }
- pjmlp 5y agoYou can do that if you wish, they are called module interface units.