繁体   English   中英

string_char_traits <char> 在C ++ 11中用于GNU / G ++ 4.9(早期版本2.95.3)

[英]string_char_traits<char> in C++11 for GNU/G++ 4.9 (earlier 2.95.3)

我有一些遗留的C ++代码(用于使用GNU g ++ 2.95.3进行编译),具有以下声明: std::basic_string<char,string_char_traits<char>,malloc_alloc> x; 头文件是

#include <std/bastring.h>

现在,我正在迁移到GU g ++ 4.9,我收到此错误:1。找不到std/bastring.h 2.当我将#include <std/bastring.h>更改为#include <string> ,我是收到以下错误:

error: 'string_char_traits' was not declared in this scope
std::basic_string<char,string_char_traits<char>,malloc_alloc> x;
error: template argument 2 is invalid
std::basic_string<char,string_char_traits<char>,malloc_alloc> x;
error: expected unqualified-id before ',' token
std::basic_string<char,string_char_traits<char>,malloc_alloc> x;
                                              ^

在GNU g ++ 4.9下需要指导/帮助才能使这个可编辑

尽管出版了ISO / IEC 14882:1998,但GCC 2.95.3并非符合C ++ 98标准的编译器。 我们谈论的是一个15岁的编译器运行在上帝可怕的谁知道什么 - 来自90年代的非标准代码。 首先,这是bastring.h的一个片段:

// Written by Jason Merrill based upon the specification by Takanori Adachi
// in ANSI X3J16/94-0013R2.

...

// NOTE : This does NOT conform to the draft standard and is likely to change
#include <alloc.h>

我不知道ANSI X3J16/94-0013R2是什么,但它绝对与ISO C ++ 98无关。 malloc_alloc被发现alloc.h ,如果由于某种原因,你要明确想要mallocfree ,以在分配器使用。

无论如何,你的代码库无疑必须从头开始重写。 std::basic_string<char,string_char_traits<char>,malloc_alloc> x; 可以用std::string替换。 但是,我对其他标准前代码的恐怖感到不寒而栗。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM