摘要
C++是一种静态类型语言,这就使实现可以容纳不同种类型元素的容器——元组变得十分困难。C++的标准容器库STL 虽然提供了丰富的容器,但其都只能容纳相同类型的元素,没有提供对元组容器的支持。其实C++的模板机制为它的静态类型系统增加了很大的灵活性,再使用一些其它的技巧,使得实现元组容器成为可能。wyf::tuple 就是如此实现的一个元组容器的程序库。wyf::tuple 不但可以保证类型安全,并且是高效的。测试数据表明,它要比一些动态语言如Python 中的类似容器高效得多。
To implement tuple in C++ is very difficult, because of its static type system. STL has many containers, but it does not include tuple. However, the template enhances the flexibility of static type system greatly. Using template and some other techniques, it is possible to design a tuple. WYF:: tuple is container using this approach. It is type-safe and effective. The performance tests show that wyf:: type is far more effective than the similar container in such dynamic language like python.
出处
《计算机工程与设计》
CSCD
北大核心
2005年第3期770-773,776,共5页
Computer Engineering and Design