I'm following this example of how to write modules in c++ 20: https://learn.microsoft.com/en-us/cpp/cpp/tutorial-named-modules-cpp?view=msvc-170 and I continue getting an error C7621 "module partition 'XXX' for module unit 'XXX' was not found.
Following the example I've created the next ixx *primary module interface:
export module Chapter01;
export import :Question01;
I've then added the ixx module partition file:
export module Chapter01:Question01;
import <iostream>;
import <set>;
using namespace std;
export bool IsUnique(const std::string& str);
And the cpp implementation file:
module Chapter01:Question01;
import <iostream>;
import <set>;
using namespace std;
bool IsUnique(const std::string& str)
{
set<char> charset = set<char>();
for (const char c : str)
{
if (charset. Contains(c))
{
return false;
}
charset. Insert(c);
}
return true;
}
And I keep getting a C7621: module partition 'Question01' for module unit 'Chapter01' was not found
Looking at the example over and over again I can't seem to find the difference.
Removing the cpp file entirely and putting the implementation in the ixx file fixes the issue, but I would still like to understand why the separation doesn't work.
P.S. What is the best practice when working with modules? To separate the ixx and cpp files or to just include ixx files?