Please take note of the updates at the end of this post.
Update: I have created a public project on GitHub for this library!
I would like to have a single template that once and for all takes care of pretty-printing all STL containers via operator<<. In pseudo code, I'm looking for something like this:
template<container C, class T, String delim = ", ", String open = "[", String close = "]">
std::ostream & operator<<(std::ostream & o, const C<T> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用第三方库中的函数,并期望输入流对象,其中传输二进制文件数据.
签名看起来像这样:
doSomething(const std::string& ...,
const std::string& ...,
std::istream& aData,
const std::string& ...,
const std::map<std::string, std::string>* ...,
long ...,
bool ...);
Run Code Online (Sandbox Code Playgroud)
由于我不能改变/改变这个第三方的lib /功能,我必须适应"我的"代码.在调用的地方,我有一个std :: vector,它包含了预期在istream对象中传递的数据.目前,我将向量复制到流中,通过迭代并使用<<运算符逐字节复制.
我强烈怀疑可能有一种更有效/方便的方式,但迄今为止找不到任何有用的东西.非常感谢任何帮助/您的想法.
最好,JR