Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to output C++ range-v3 to ostringstream?

This range-v3 example doesn't compile with Visual C++ version 15.9:

auto letters = ranges::view::iota('a','g');
std::ostringstream out;
out << letters;

Is this by design? What is the way to output ranges to ostringstream?

like image 654
Paul Jurczak Avatar asked Nov 26 '25 08:11

Paul Jurczak


1 Answers

This program:

#include <iostream>
#include <sstream>
#include <range/v3/view/iota.hpp>

int main() {
    auto letters = ranges::view::iota('a','g');
    std::ostringstream out;
    out << letters;
    std::cout << out.str();
}

works for me with VS 2017 15.9.3 and range-v3 installed by vcpkg. It outputs [a,b,c,d,e,f].

like image 79
Casey Avatar answered Nov 27 '25 20:11

Casey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!