Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unrecoverable error importing module 'std' with std::ranges::views::pairwise_transform #4404

Closed
davidhunter22 opened this issue Feb 18, 2024 · 2 comments · Fixed by #4420
Closed
Labels
bug Something isn't working fixed Something works now, yay! modules C++23 modules, C++20 header units

Comments

@davidhunter22
Copy link

I ran into the following in VS 17.10.0 Preview 1.0, I have not tested to see if this is a regression or new.
The following code

import std;
//#include <ranges>
//#include <vector>

void main( )
{
    std::vector<double> points { 1.6, 2.6, 99.9 };

    auto fn = []( double a, double b ) -> double
    {
        return a + b ;
    };

    auto x = points | std::ranges::views::pairwise_transform( fn );

    auto y = std::ranges::to<std::vector>( x );
}

compiles fine and does what I expect when I use the #includes however when I switch to the import std; i get

C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33521\include\ranges(8957,9): error C1116: unrecoverable error importing module 'std'.  Specialization of 'std::invoke_result_t' with arguments '_Fn, _Ty...'

Hopefully this is already fixed by the upcoming stuff in #1694 but I'm not really able to tell.

@StephanTLavavej StephanTLavavej added bug Something isn't working modules C++23 modules, C++20 header units labels Feb 20, 2024
@frederick-vs-ja
Copy link
Contributor

Possible workaround?

diff --git a/stl/inc/ranges b/stl/inc/ranges
index 1da7e946..fb24db67 100644
--- a/stl/inc/ranges
+++ b/stl/inc/ranges
@@ -8976,7 +8976,7 @@ namespace ranges {
 
     template <class _Fn, class _Ty, size_t... _Indices>
     struct _Invoke_result_with_repeated_type_impl<_Fn, _Ty, index_sequence<_Indices...>> {
-        using type = invoke_result_t<_Fn, _Repeat_type<_Ty, _Indices>...>;
+        using type = decltype(_STD invoke(_STD declval<_Fn>(), _STD declval<_Repeat_type<_Ty, _Indices>>()...));
     };
 
     template <class _Fn, class _Ty, size_t _Nx>

@StephanTLavavej
Copy link
Member

Thanks @frederick-vs-ja - I'm going to go with a different workaround since I don't trust pack expansions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Something works now, yay! modules C++23 modules, C++20 header units
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants