【发布时间】:2017-03-06 02:18:46
【问题描述】:
我正在用非托管代码编写对 WCF 调用的响应。问题是我有一个整数,我想将其转换为WS_STRING 并回复。
std::towstring 仅转换为 wstring 而不会转换为 WS_STRING。我怎样才能做到这一点?
我看到有一个较旧的帖子有类似的问题,但似乎没有答案。
int i = 100;
responseWsString = std::to_wstring(i);
//Throws compiler error : No operator '=' matches operands of type WS_STRING = std::wstring
这是预期的,因为类型不同。另一个线程提到const_cast<> 不是一个好方法。那么如何解决这个简单的问题,将 int 转换为 WS_STRING 呢?
这是上一篇的链接: Convert wstring to WS_STRING
【问题讨论】:
标签: c++ wcf int const-cast