The following program fails to compile in MSVC. It works fine in GCC and Clang. Maybe it's a bug in <tuple>.
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 &
]
Program compiles.
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>.Command-line test case
Expected behavior
Program compiles.
STL version
Visual Studio 17.7.2
Additional context
https://godbolt.org/z/fhs86zGzz