range-v3 how to action::join with delimiter

后端 未结 1 1317
清酒与你
清酒与你 2021-01-16 08:47

I get range-v3 for MSVC from git. And compile by MSVC C++14 compiler.

Consider code:

auto getter2 = [](const std::string&r) { return r+r; };
std:         


        
相关标签:
1条回答
  • 2021-01-16 09:13

    Guessing: A string literal isn't a range. Try passing std::string(",") or view::c_str(",") to view::join instead.

    UPDATE: Ah. Try this instead (tested with clang trunk):

    #include <range/v3/all.hpp>
    #include <vector>
    #include <iostream>
    int main()
    {
        using namespace ranges;
        std::vector<std::string> vv = { "11","22", "33" };
        auto getter2 = [](auto&r) { return view::concat(r, r); };
    
        std::cout << (vv | view::transform(getter2) 
                         | view::join(',')
                         | to_<std::string>()) << std::endl;
        return 0;
    }
    
    0 讨论(0)
提交回复
热议问题