A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
problem calling template function defined in module
I was unable to make a minimal working example. I hope this suffices. If not, please let me know what other information is helpful.
In a module called unit_spatial.ixx I have the following snippet:
template <typename RTree, typename Geometry>
inline auto k_within(RTree const &map, Geometry const &geometry, float radius, unsigned k = std::numeric_limits<int>::max()) {
auto nearest = std::ranges::subrange(map.qbegin(bgi::nearest(geometry, k)), map.qend()); // compiler doesn't complain about this
auto f = std::ranges::views::filter( is_within(geometry, radius)); // compiler ok with this
auto g = std::ranges::views::take_while(is_within(geometry, radius)); // compiler ok with this too
//return nearest | f; // client would compile if I used f
return nearest | g; // fails to compile a client calling this function: fatal error C1116: unrecoverable error importing module 'unit_spatial'
}
In the client I have imported unit_spatial and have the following snippet
// ....
Point2D origin(0, 0);
UnitMap map(us.begin(), us.end()); // create packed map
auto rng = k_within(map, origin, 5.0f, 100); // (1) search 100 units for those within radius <= 5; Fails as described above
I'm using boost geometry for my RTree and MS STL library on VS 2022 preview 7. Apart from noticing the different signatures of std::ranges::views::filter and std::ranges::views::take_while, I can't figure out how this could be.
Also, If I call the std::ranges::views::take_while(is_within(geometry, radius)) from the client that works too. It only fails when I call into a module that tries the same thing.
The compiler error is uninformative to me:
on line (1). fatal error C1116: unrecoverable error importing module 'unit_spatial'