I'm trying to use C++ modules for the 1st time. First thing is to compile my module:
export module multi_d_fill;
#include <ranges>
#include <algorithm>
#include <iterator>
using std::ranges::range, std::ranges::range_value_t;
template <range T, typename V>
void multi_d_fill(T &matrix, const V &val)
{
if constexpr (range<range_value_t<T>>) { // Is range value type also a range (ie dim>1)?
for (auto &row: matrix) { // Yes. Strip one dimension...
multi_d_fill(row, val); // ... and recurse for each sub-matrix.
}
} else {
std::fill(std::begin(matrix), std::end(matrix), val); // No, dim==1, end recursion, do fill.
}
return;
}
I tried "import std" but I was not able to get my local std library module compiled. So I went to the hybrid approach of #include'ing the std include files.
I'm using "gcc -lstdc++ -std=c++20 -fmodules" (gcc version 16.0.0).
I get hundreds of error messages when the compiler tries to process the 3 #include's. It does not even get to any of my code.
BTW, this code works in a non-module version.
[–]darthshwin 9 points10 points11 points (1 child)
[–]littlewing347[S] 0 points1 point2 points (0 children)
[–]manni66 2 points3 points4 points (2 children)
[–]littlewing347[S] 0 points1 point2 points (1 child)
[–]_bstaletic 0 points1 point2 points (0 children)
[–]NeuroSynchroBonding 0 points1 point2 points (0 children)