【发布时间】:2020-10-14 09:21:23
【问题描述】:
考虑以下代码:
#include <cctype>
#include <ranges>
constexpr inline auto filter_upper = std::views::filter(::isupper);
新的范围适配器 filter_upper 可以与全局旧 c 函数 ::isupper 一起正常工作,但如果我替换为 std::isupper,我会收到此编译器错误:
<source>:4:69: error: no match for call to '(const std::ranges::views::__adaptor::_RangeAdaptor<std::ranges::views::<lambda(_Range&&, _Pred&&)> >) (<unresolved overloaded function type>)'
4 | constexpr inline auto filter_upper = std::views::filter(std::isupper);
| ^
In file included from <source>:1:
/opt/compiler-explorer/gcc-10.2.0/include/c++/10.2.0/ranges:1102:4: note: candidate: 'constexpr auto std::ranges::views::__adaptor::_RangeAdaptor<_Callable>::operator()(_Args&& ...) const [with _Args = {}; _Callable = std::ranges::views::<lambda(_Range&&, _Pred&&)>]'
1102 | operator()(_Args&&... __args) const
| ^~~~~~~~
问题出在哪里?
【问题讨论】:
标签: c++ c++20 std-ranges