草庐IT

LCD_write_chinese_string

全部标签

tablenameattribute.tablenameattribute(String)之间的模棱两可的错误

我只是升级了.Netv4.0至4.6.1并最终在应用程序中使用的SQL相关属性(tableName,primarykey,列)的歧义错误。我试图弄清楚哪个DLL导致此错误。我正在看到错误tablenameattribute.tablenameattribute(字符串)首要的关键。columnAttribute...等我想知道哪个dll我必须删除看答案歧义是在实体框架和system.com.ponentmodel.dataannotations之间

c++ - 为什么编译器不能优化 std::string concat?

我尝试这样简单的代码:#include#includeintmain(){conststd::strings=std::string("a")+"b";puts(s.c_str());return0;}我希望编译器(gcc4.8.2/clang3.5.0)优化这样的代码intmain(){puts("ab");return0;}但我得不到这样的结果,我尝试了不同的选项,如“-Ofast”、“-flto”、“-static-libstdc++”,但总是在反汇编输出中看到三个函数调用:...callq0x4017e0...callq0x401690...callq0x401490第一个是调

c++ - 变体 bstr 到 std::string 转换的默认编码

我有一个从MSXMLDOM中提取的变体bstr,所以它是UTF-16格式的。我试图找出此转换发生的默认编码:VARIANTvtNodeValue;pNode->get_nodeValue(&vtNodeValue);stringstrValue=(char*)_bstr_t(vtNodeValue);根据测试,我认为默认编码是Windows-1252或Ascii,但我不确定。顺便说一句,这是我正在修复并将变体转换为wstring并通过调用WideCharToMultiByte进行多字节编码的代码块。谢谢! 最佳答案 operator

c++ - boost::ifind_first 与 std::string 对象

我正在尝试使用boost字符串算法进行不区分大小写的搜索。这里是新手。如果我以这种方式使用它,我会得到一个错误。std::stringstr1("Helloworld");std::stringstr2("hello");if(boost::ifind_first(str1,str2))somecode;转换为char指针可以解决问题。boost::ifind_first((char*)str1.c_str(),(char*)str2.c_str());有没有办法直接搜索std::string对象?此外,也许还有另一种方法可以通过不区分大小写的搜索来了解字符串是否存在于另一个字符串中?

c++ - C++ 中的 string[length()] 可以吗?

我同事的代码是这样的:voidcopy(std::stringconst&s,char*d){for(inti=0;i他的应用程序崩溃了,我认为这是因为访问s超出了范围,因为条件应该只达到s.size()-1。但我旁边的其他人说过去曾讨论过这是合法的。谁能帮我解决这个问题? 最佳答案 让我们撇开*d的可能性无效,因为这与问题似乎针对的内容无关:是否std::stringoperator[]()在访问索引std::string::size()处的“元素”时具有明确定义的行为.C++03标准对string::operator[]()的描

c++ - 为什么 std::make_move_iterator 适用于 vector<string> 但不适用于 vector<int>

我期待std::make_move_iterator总是会move内容,但似乎不会。看起来是在vector中move元素但不在vector.请看下面的代码片段:#include#include#include#includevoidmoveIntVector(){std::coutv1;for(unsignedi=0;iv2(std::make_move_iterator(v1.begin()+5),std::make_move_iterator(v1.end()));std::coutv1;for(unsignedi=0;iv2(std::make_move_iterator(v1.

c# - C# 中的 std::string?

我以为问题出在我的C++函数中,但我试过了C++dll中的C++函数:bool__declspec(dllexport)OpenA(std::stringfile){returntrue;}C#代码:[DllImport("pk2.dll")]publicstaticexternboolOpenA(stringpath);if(OpenA(@"E:\asdasd\"))我得到一个内存损坏的异常,为什么?如果我删除std::string参数,它工作得很好,但是对于std::string它不起作用。 最佳答案 std::string和c

c++ - const std::map<boost::tuples::tuple, std::string>?

//BOOSTIncludes#include//Boost::Assign#include//Boost::Assign::List_Of#include//Boost::Assign::Map_List_Of#include//Boost::Tuples//STDIncludes#include#include#include//Usingnamespacesusingnamespacestd;usingnamespaceboost;usingnamespaceboost::assign;//Constsconstmapquery_map=map_list_of("4556_SEL

c++ - 如何将 vector<char*> 转换为 vector<string>/string

我们有一个返回vector的遗留方法字符指针,即vector.现在,我只需要处理字符串(std::string)。我该怎么做?这个问题听起来很简单,但我遇到了几个网站,它们描述了这些考虑因素可能会导致内存泄漏。现在,我要么想要一个vector甚至是没有任何内存泄漏的字符串。我该怎么做? 最佳答案 转换非常简单:std::vectorugly_vector=get_ugly_vector();std::vectornice_vector(ugly_vector.begin(),ugly_vector.end());不过,一旦你这样做了

c++ - 如何提高键类型为 std::string 的 map 查找的性能?

我正在使用std::map(VC++实现),通过map的find方法进行查找有点慢。键类型是std::string。我可以通过map的自定义键比较覆盖来提高此std::map查找的性能吗?例如,也许std::stringstring::size()比较?还有其他加快比较速度的想法吗?在我的情况下,map将始终包含更新:map包含文件路径。更新2:map的元素经常变化。 最佳答案 首先,关闭所有的性能分析和调试开关。这些会极大地减慢STL。如果不是这样,部分问题可能是字符串的前80-90%是相同的。这对map来说不一定是坏事,但它适用