gpt4 book ai didi

c++ - GNU/G++ 4.9(2.95.3 之前的版本)的 C++11 中的 string_char_traits

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:47:04 24 4
gpt4 key购买 nike

我有一些遗留的 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_allocalloc.h 中找到, 如果出于某种原因你想明确想要 mallocfree在分配器中使用。

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

关于c++ - GNU/G++ 4.9(2.95.3 之前的版本)的 C++11 中的 string_char_traits<char>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37698059/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com