有没有办法让 C 预处理器更改我正在使用的 STL 实现?
Is there a way to have the C preprocessor change which STL implementation I'm using?
我沿着
的行中的C 代码#include<vector>
std::vector<double> foo;
我需要为嵌入式平台编译此代码,该平台使用称为USTL的STL的自定义实现。使用它需要#include
ustl.h
标头文件,并且所有STL类都在另一个名称空间中定义。因此,以上片段应成为
#include<ustlh.>
ustl::vector<double> foo;
我不想修改源代码,因为它是其他非安装应用程序使用的库代码。我正在考虑使用C预处理器将#include<vector>
转换为#include<ustl.h>
,但这似乎是不可能的(宏名称必须是有效的标识符)。
有其他方法可以让C预处理器这样做吗?还是另一种方式不会暗示修改原始源代码?
您必须做类似的事情:
#ifdef USE_USTL
#include <ustl.h>
using ustl::vector;
#else
#include <vector>
using std::vector;
#endif
vector<double> foo;
相关文章:
- 为什么使用 NDK 不能存在不同的 stl 实现?
- glibcxx STL 在实现 std::valarray::sum() 时是否不正确?
- 默认赋值运算符如何在实际 STL 中实现
- hashtable :如何理解这种基于STL中List的hashtable实现
- 如何知道用于实现标准代码段的确切数据结构和算法,例如在C++STL中?
- 使用 Boost HOF 实现 STL 漂亮打印
- 如何在C++中重新实现包含指针的 STL 容器的类的迭代器
- 在C++中实现无STL和无类的最小堆
- 我可以期望某些 STL 函数实现是可自动矢量化的吗?
- 使用 C++ STL 的数组实现
- 我应该如何在恒定长度的 STL 样式数据结构中实现max_size?
- C STL中如何实现Deque
- 错误试图实现STL迭代器
- 关于 c++ stl 谓词的实现
- 为什么不是条件 *First1 == * First2 ??(C++ STL 包括函数实现)
- 使用值类在C 中实现STL MAP
- 如何实现STL容器中对象的快速释放
- 应该如何为自定义类实现STL功能
- 如何实现 STL 风格的迭代器并避免常见的陷阱
- 说出一个实现STL兼容序列容器的好指南)