Boost.Container模块中的显式实例表实现及其测试程序
Boost.Container是一个用于提供容器和容器适配器的高质量C++库。在其中,显式实例表(Explicit Instantiation Table)是Boost.Container模块中的一项重要特性,它可以大大减少生成代码的数量,提高编译速度。
下面,我们将演示如何使用显式实例表,以及如何编写测试程序对其进行测试。首先,我们需要声明一个简单的数据结构和一些函数:
// 在头文件example.hpp中声明一个简单的类和若干函数
#include <iostream>
class Example {
public:
Example(int value = 0): value_(value) {}
void print() const { std::cout << value_ << std::endl; }
private:
int value_;
};
void example_function1(const Example& x) {
std::cout << "example_function1: ";
x.print();
}
void example_function2(const Example& x, int n) {
std::cout << "example_function2: ";
for (int i = 0; i < n; ++i)
x.print();
}
// ...
订阅专栏 解锁全文
195



被折叠的 条评论
为什么被折叠?



