我从 git 获得 MSVC 的 range-v3。并由 MSVC C++14 编译器编译。
考虑代码:
auto getter2 = [](const std::string&r) { return r+r; };
std::vector<std::string> vv = { "11","22", "33" };
std::cout << (vv | view::transform(getter2) | action::join) << std::endl;
它按预期工作。但我想添加分隔符加入,如果我写
std::cout << (vv | view::transform(getter2) | action::join(",")) << std::endl;
代码未编译。怎么了?大量编译器错误如下:
1>d:\sources\ranges_test\ranges_test.cpp(28): error C2672: 'operator __surrogate_func': no matching overloaded function found
1>d:\sources\ranges_test\ranges_test.cpp(28): error C2783: 'unknown-type ranges::v3::action::action<ranges::v3::action::join_fn>::operator ()(Rng &,Rest &&...) const': could not deduce template argument for '__formal'
1>d:\sources\fingrad\dev.fingrad\src\vc\lib\range\v3\action\action.hpp(120): note: see declaration of 'ranges::v3::action::action<ranges::v3::action::join_fn>::operator ()'
1>d:\sources\ranges_test\ranges_test.cpp(28): error C2893: Failed to specialize function template 'unknown-type ranges::v3::action::action<ranges::v3::action::join_fn>::operator ()(T &&,Rest &&...) const'
1>d:\sources\ranges_test\ranges_test.cpp(28): note: With the following template arguments:
1>d:\sources\ranges_test\ranges_test.cpp(28): note: 'T=const char (&)[2]'
1>d:\sources\ranges_test\ranges_test.cpp(28): note: 'Rest={}'
1>d:\sources\ranges_test\ranges_test.cpp(28): note: 'A=ranges::v3::action::join_fn'
更新
不仅 MSVC 端口行为如此,这里也是如此