无法将字符串流传递给构造函数
我正在使用 SimpleINI 将值获取到 std::stringstream my_string;
-
CSimpleIniCaseA::TNamesDepend::const_iterator i;
for (i = values.begin(); i != values.end(); ++i)
my_string << i->pItem <<"\n";
cout<<my_string.str()<<endl;
cout 工作正常。我可以在控制台上打印值。
但是,当我像这样将此字符串 steam 传递给 BOOST ASIO Server 构造函数时 -
server tcp(tcp_service,my_string.str());
我遇到编译器错误 -
‘std::basic_streambuf<_CharT, _Traits>& std::basic_streambuf<_CharT, _Traits>::operator=(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char, _Traits = std::char_traits<char>]’ is private
我能够传递其他数据类型,例如 char *
,但不能传递字符串 steam。怎么了?
I am using SimpleINI to get values into std::stringstream my_string;
-
CSimpleIniCaseA::TNamesDepend::const_iterator i;
for (i = values.begin(); i != values.end(); ++i)
my_string << i->pItem <<"\n";
cout<<my_string.str()<<endl;
cout is working fine. I am able to print values on console.
But when I pass this string steam to BOOST ASIO Server constructor like this-
server tcp(tcp_service,my_string.str());
I get below compiler error-
‘std::basic_streambuf<_CharT, _Traits>& std::basic_streambuf<_CharT, _Traits>::operator=(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char, _Traits = std::char_traits<char>]’ is private
I am able to pass other data types like char *
, but not string steam. What is wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你说你做了类似的事情
但是你将一个字符串传递给构造函数,而不是字符串流。
更改构造函数,或从
my_string.str()
中删除.str()
You said you did something like
But there you pass a string to the constructor, not a stringstream.
Either change your constructor, or remove the
.str()
frommy_string.str()