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

<future>: Can't pass std::ranges algorithm to std::async #3995

Closed
leejy12 opened this issue Aug 27, 2023 · 4 comments
Closed

<future>: Can't pass std::ranges algorithm to std::async #3995

leejy12 opened this issue Aug 27, 2023 · 4 comments
Labels
invalid This issue is incorrect or by design

Comments

@leejy12
Copy link
Contributor

leejy12 commented Aug 27, 2023

Describe the bug

The following program fails to compile in MSVC. It works fine in GCC and Clang. Maybe it's a bug in <tuple>.

#include <ranges>
#include <future>
#include <iostream>
#include <algorithm>

int main()
{
    const auto numbers = std::views::iota(0, 1000);

    auto evens = std::async(std::ranges::count_if, numbers, [](auto n) { return n % 2 == 0; });

    std::cout << evens.get() << std::endl;
}

Command-line test case

C:\Temp>cl /EHsc /W4 /WX /std:c++20 repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.37.32822 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

repro.cpp
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): error C2661: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple': no overloaded function takes 3 arguments
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(533): note: could be 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,std::pair<_First,_Second> &&)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,std::pair<_First,_Second> &&)': could not deduce template argument for 'std::pair<_First,_Second> &&' from '_Ty'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
        and
        [
            _Ty=main::<lambda_1>
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(527): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,const std::pair<_First,_Second> &)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,const std::pair<_First,_Second> &)': could not deduce template argument for 'const std::pair<_First,_Second> &' from '_Ty'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
        and
        [
            _Ty=main::<lambda_1>
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(505): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,std::tuple<_Types2...> &&)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,std::tuple<_Types2...> &&)': could not deduce template argument for 'std::tuple<_Types2...> &&' from '_Ty'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
        and
        [
            _Ty=main::<lambda_1>
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(497): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,const std::tuple<_Types2...> &)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,const std::tuple<_Types2...> &)': could not deduce template argument for 'const std::tuple<_Types2...> &' from '_Ty'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
        and
        [
            _Ty=main::<lambda_1>
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(480): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>> &&)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>> &&)': could not deduce template argument for '__formal'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(476): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,const std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>> &)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,const std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>> &)': could not deduce template argument for '__formal'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(470): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,_This2 &&,_Rest2 &&...)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,_This2 &&,_Rest2 &&...)': could not deduce template argument for '__formal'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(462): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,const _This &,const std::ranges::iota_view<_Ty1,_Ty2> &,const main::<lambda_1> &)'
        with
        [
            _Ty1=int,
            _Ty2=int,
            _This=std::ranges::_Count_if_fn
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &,const _This &,const std::ranges::iota_view<_Ty1,_Ty2> &,const main::<lambda_1> &)': expects 5 arguments - 3 provided
        with
        [
            _Ty1=int,
            _Ty2=int,
            _This=std::ranges::_Count_if_fn
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(455): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::allocator_arg_t,const _Alloc &)': expects 2 arguments - 3 provided
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(416): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::pair<_Other1,_Other2> &&) noexcept(<expr>)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::pair<_Other1,_Other2> &&) noexcept(<expr>)': expects 1 arguments - 3 provided
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(410): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(const std::pair<_Other1,_Other2> &) noexcept(<expr>)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(const std::pair<_Other1,_Other2> &) noexcept(<expr>)': expects 1 arguments - 3 provided
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(388): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::tuple<_Types1...> &&) noexcept(<expr>)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(std::tuple<_Types1...> &&) noexcept(<expr>)': expects 1 arguments - 3 provided
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(380): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(const std::tuple<_Types1...> &) noexcept(<expr>)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(const std::tuple<_Types1...> &) noexcept(<expr>)': expects 1 arguments - 3 provided
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(361): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_This2 &&,_Rest2 &&...) noexcept(<expr>)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_This2 &&,_Rest2 &&...) noexcept(<expr>)': could not deduce template argument for '__formal'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(352): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(const _This &,const std::ranges::iota_view<_Ty1,_Ty2> &,const main::<lambda_1> &) noexcept(<expr>)'
        with
        [
            _Ty1=int,
            _Ty2=int,
            _This=std::ranges::_Count_if_fn
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(const _This &,const std::ranges::iota_view<_Ty1,_Ty2> &,const main::<lambda_1> &) noexcept(<expr>)': could not deduce template argument for '__formal'
        with
        [
            _Ty1=int,
            _Ty2=int,
            _This=std::ranges::_Count_if_fn
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(345): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(void) noexcept(<expr>)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(void) noexcept(<expr>)': expects 0 arguments - 3 provided
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(338): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,const _Alloc &,_Tpl &&)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,const _Alloc &,_Tpl &&)': could not deduce template argument for '__formal'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(335): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,const _Alloc &,_Tpl &&,std::integer_sequence<size_t,_Indices2...>)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,const _Alloc &,_Tpl &&,std::integer_sequence<size_t,_Indices2...>)': expects 4 arguments - 3 provided
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(329): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,const _Alloc &,_This2 &&,_Rest2 &&...)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,const _Alloc &,_This2 &&,_Rest2 &&...)': could not deduce template argument for '__formal'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(323): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,_Tpl &&)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,_Tpl &&)': expects 2 arguments - 3 provided
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(320): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,_Tpl &&,std::integer_sequence<size_t,_Indices1...>)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,_Tpl &&,std::integer_sequence<size_t,_Indices1...>)': could not deduce template argument for 'std::integer_sequence<size_t,_Indices1...>' from '_Ty'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
        and
        [
            _Ty=main::<lambda_1>
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\tuple(316): note: or       'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,_This2 &&,_Rest2 &&...)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: 'std::tuple<std::ranges::_Count_if_fn,std::ranges::iota_view<_Ty1,_Ty2>,main::<lambda_1>>::tuple(_Tag,_This2 &&,_Rest2 &&...)': could not deduce template argument for '__formal'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: while trying to match the argument list '(const std::ranges::_Count_if_fn, const std::ranges::iota_view<_Ty1,_Ty2>, _Ty)'
        with
        [
            _Ty1=int,
            _Ty2=int
        ]
        and
        [
            _Ty=main::<lambda_1>
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1428): note: while compiling class template member function 'std::_Fake_no_copy_callable_adapter<const std::ranges::_Count_if_fn &,const std::ranges::iota_view<_Ty1,_Ty2> &,_Ty>::_Fake_no_copy_callable_adapter(const std::ranges::_Count_if_fn &,const std::ranges::iota_view<_Ty1,_Ty2> &,_Ty &&)'
        with
        [
            _Ty1=int,
            _Ty2=int,
            _Ty=main::<lambda_1>
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1467): note: see the first reference to 'std::_Fake_no_copy_callable_adapter<const std::ranges::_Count_if_fn &,const std::ranges::iota_view<_Ty1,_Ty2> &,_Ty>::_Fake_no_copy_callable_adapter' in 'std::async'
        with
        [
            _Ty1=int,
            _Ty2=int,
            _Ty=main::<lambda_1>
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1468): note: see reference to class template instantiation 'std::_Fake_no_copy_callable_adapter<const std::ranges::_Count_if_fn &,const std::ranges::iota_view<_Ty1,_Ty2> &,_Ty>' being compiled
        with
        [
            _Ty1=int,
            _Ty2=int,
            _Ty=main::<lambda_1>
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\future(1478): note: see reference to function template instantiation 'std::future<__int64> std::async<const std::ranges::_Count_if_fn&,const std::ranges::iota_view<_Ty1,_Ty2>&,_Ty>(std::launch,_Fty,const std::ranges::iota_view<_Ty1,_Ty2> &,_Ty &&)' being compiled
        with
        [
            _Ty1=int,
            _Ty2=int,
            _Ty=main::<lambda_1>,
            _Fty=const std::ranges::_Count_if_fn &
        ]
repro.cpp(10): note: see reference to function template instantiation 'std::future<__int64> std::async<const std::ranges::_Count_if_fn&,const std::ranges::iota_view<_Ty1,_Ty2>&,main::<lambda_1>>(_Fty,const std::ranges::iota_view<_Ty1,_Ty2> &,main::<lambda_1> &&)' being compiled
        with
        [
            _Ty1=int,
            _Ty2=int,
            _Fty=const std::ranges::_Count_if_fn &
        ]

Expected behavior

Program compiles.

STL version

Visual Studio 17.7.2

Additional context

https://godbolt.org/z/fhs86zGzz

@frederick-vs-ja
Copy link
Contributor

ranges algorithms are "Niebloids" and not necessary customized point objects (although implementations can make any of Niebloids a CPO). You are not supposed to be able to copy them.

@leejy12
Copy link
Contributor Author

leejy12 commented Aug 27, 2023

@frederick-vs-ja I see, thank you!

@leejy12 leejy12 closed this as completed Aug 27, 2023
@CaseyCarter CaseyCarter added the invalid This issue is incorrect or by design label Oct 17, 2023
@fsb4000
Copy link
Contributor

fsb4000 commented Oct 18, 2023

Hi @leejy12 !
Look at the PR: #4098
Casey wrote:

I can confirm that the repro from #3995 compiles and runs just fine with this change.

I think #4098 will be in VS 2022 17.9 Preview 2

@frederick-vs-ja
Copy link
Contributor

As said here, you can use std::ref(std::ranges::count_if) in the meanwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This issue is incorrect or by design
Projects
None yet
Development

No branches or pull requests

4 participants