C++ 没有合适的用户定义的从utility::string\u t到std::string的转换
我使用卡萨布兰卡C++休眠库来制作HTTP请求。 问题是,这将提供一个utility::string\u t string作为输出,我无法找到任何方法将其转换为经典的std::string。有什么想法吗C++ 没有合适的用户定义的从utility::string\u t到std::string的转换,c++,string,casablanca,C++,String,Casablanca,我使用卡萨布兰卡C++休眠库来制作HTTP请求。 问题是,这将提供一个utility::string\u t string作为输出,我无法找到任何方法将其转换为经典的std::string。有什么想法吗 client.request(methods::GET).then([](http_response response) { if(response.status_code() == status_codes::OK) { string_t s = response.extrac
client.request(methods::GET).then([](http_response response)
{
if(response.status_code() == status_codes::OK)
{
string_t s = response.extract_string().get();
}
});
如果您从GITHUB中看到C++的REST SDK的文档,您会发现一个<代码> TyPulf< /Calp><
所以不需要转换它。这两种类型都是相同的。根据您编译的平台,将
实用工具::string_t
类型定义为std::wstring
(在Windows上)或std::string
(在Linux/OSX上)
要获得经典的utf-8std::string
而不考虑平台,请查看utility::conversions::To_utf8string
在Windows Phone 8.1上有以下定义:
typedef std::wstring string_t;
我用了这个:
string_t toStringT = U("sample");
std::string fromStringT(toStringT.begin(), toStringT.end());
或:
实用工具::字符串不是std::字符串的类型定义吗?问题出在哪里?如果您使用,那么last REST SDK有一些类型问题。最新版本有:typedef std::wstring string\u t;作为参考,这是TAT在Windows上为我工作的唯一一个,用C++ REST SDK 2.7.0。实用工具::string\u t未被接受为std::string。这仅适用于非Windows。在Windows上,此typedef看起来像
typedef std::wstring string\t代码>实用程序确实支持类似于实用程序::转换::to_utf8string
string_t toStringT = U("sample");
std::string fromStringT(toStringT.begin(), toStringT.end());
std::string fromStringT(conversions::to_utf8string(toStringT));