第三章 深度探索元函数 (1)[8]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 pongba 的 blog

   mpl::int_<0>, mpl::int_<1>, mpl::int_<0>, mpl::int_<0>

 , mpl::int_<0>, mpl::int_<0>, mpl::int_<0>

> length;

...

 

...你很快就会觉得这写起来实在太累人。更糟糕的是,这样的代码难于阅读和验证。代码的本质信息,也就是每个基本单位的幂次,被埋在重复的语法“噪音”中。因此,mpl相应还提供了整型序列外覆类,它允许我们写出类似下面的代码:

 

#include <boost/mpl/vector_c.hpp>

 

typedef mpl::vector_c<int,1,0,0,0,0,0,0> mass;

typedef mpl::vector_c<int,0,1,0,0,0,0,0> length; // or position

typedef mpl::vector_c<int,0,0,1,0,0,0,0> time;

typedef mpl::vector_c<int,0,0,0,1,0,0,0> charge;

typedef mpl::vector_c<int,0,0,0,0,1,0,0> temperature;

typedef mpl::vector_c<int,0,0,0,0,0,1,0> intensity;

本文关键:第三章 深度探索元函数 (1)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top