stdstring

    21热度

    2回答

    可以将C-Strings或std::string创建为constexpr还是必须在运行时创建? 用gcc 4.9.2我可以这样做: constexpr const char foo[] = "blee"; (可悲的是2013年11月客户技术预览不允许Visual Studio来支持这一点:https://stackoverflow.com/a/29255013/2642059) 但即便用gcc

    1热度

    2回答

    的初始化列表是否安全char*转换为std::string内初始化列表构造的象下面这样: class MyClass{ public: MyClass(){} MyClass( char*char_Ptr_Definition_File ,char*char_Ptr_Parameters_File ,char*char_Ptr_Response_File

    3热度

    1回答

    我有一个std::string核心转储,我想在gdb中检查。打印它给我的内容为空终止字符串,但我如何访问其他std::string属性,如大小和容量?试图直接访问s.size()会导致错误,“如果没有进程调试,则不能这样做。”

    5热度

    1回答

    时我刚刚使用conda来更新我的Anaconda安装和Matplotlib从v1.4.0到v1.4.2。但是现在我所有使用Matplotlib.pyplot的Python作业都抛出异常。 即使是简单的命令: import matplotlib.pyplot as plt 抛出一个TypeError例外,他说: 无法从Unicode对象返回的std :: string 回溯告诉我异常发生在fon

    3热度

    1回答

    我刚刚注意到,我用我的C++应用程序11下面的代码(其中工程安静精): template <typename T> std::string output_streamable_to_string(T const& kObject) { std::ostringstream os; os << kObject; return os.str(); } 所以我的问

    0热度

    1回答

    我有一个奇怪的情况,我试图将std :: string转换为NSString。 我已经尝试了一般的工作原理: [NSString stringWithUTF8String:myCppString.c_str()]; 但是,我得到零返回。我认为这与奇怪的角色有关。这主要是因为我已经看到了关于调查数据如下: 通知倒置的问号。我尝试了另一个调用,通过SO浏览时发现,但它也无效:[NSString str

    3热度

    3回答

    这是一个常见问题,但我找不到满意的答案。在我的项目中,我们支持std::string,现在还必须支持宽字符串。因此,我们要搬到basic_string,但随后,事情停止工作很好和参数需要被明确地阐明: #include <string> template <typename CharT, typename Traits, typename Allocator> void foo(const

    0热度

    1回答

    如果我有一个用户定义的类型如: typedef std::string GenderType; GenderType gender; 是有可能设置gender等于std::string变量? std::string temp; temp = gender; 我需要从某种程度上GenderType提取std::string?使用stringstream这样做更安全吗?

    1热度

    2回答

    比方说,我有char buffer[64]和uint32_t length和buffer可能会或可能不会为空终止。如果空终止,则缓冲区的其余部分将填充空值。变量length保存缓冲区的长度。 我想将它复制到std::string而不会在字符串对象的末尾出现额外的空值。 本来,我想: std::string s(buffer, length); 该副本时,缓冲区填满,并在最后零点额外的空值。 我

    2热度

    3回答

    const std :: string赋值/声明中最适合什么?使用构造函数(例如,const std::string WORD("hello");)或使用相等的运算符(例如const std::string WORD= "hello";)? 这些东西在内存使用情况或时间流程上有差异吗?