Convert std :: stringstream to const char ** without memory allocation
From what I understand, it std::stringstream
appears internally not as std::string
, but rather as a collection of instances std::string
. (correct me if i'm wrong).
I have data presented as std::stringstream
and I want to pass it to a C function ( clCreateProgramWithSource
from OpenCL) that expects the data to be an array of character arrays. ( const char**)
.
Is there a way to do this without creating a single line that contains all the content of the line, like this:
std::string tmp1 = my_stringstream.str();
const char* tmp2 = tmp1.c_str();
const char** tmp3 = &tmp2;
EDIT
Follow-up question:
If this is not possible, is there some alternative std::stringstream
inheriting from std::ostream
that allows this access at a low level?
source to share
No one has answered this question yet
See similar questions:
or similar: