posts - 58,  comments - 75,  trackbacks - 0

    boost库中MPL部分提供了Data_Types。其中提供了对数字类型的一个wrapper
    有一下这么几个,都在boost::mpl名字空间下
   
    bool_ 是一个bool型的常量wrapper,头文件 #include< boost/mpl/bool.hpp >
    int_  是一个int型的常量wrapper,头文件 #include< boost/mpl/int.hpp >
    long_ 是一个long型的常量wrapper,头文件 #include< boost/mpl/long.hpp >
    size_t 是一个std::size_t型的常量wrapper,头文件 #include< boost/mpl/size_t.hpp >
    integral_c 提供了对整形的一个通用wrapper,头文件 #include< boost/mpl/integral_c.hpp >
   
    这些常量提供了如下的能力(假设一个常量类型 n )
    获得常量类型包含的类型 n::value_type
    获得常量类型的类型     n::type
    获得常量类型的值       n::value
    返回常量类型的值       n()
   
    bool_部分
   
    bool_的声明如下
   
    template< bool C >
    struct bool_;
   
    库中定义了两个常用的bool型常量,true_和false_。定义分别如下
    typedef bool_< true > true_;
    typedef bool_< false > false_;
   
    bool_特性如下
    bool_< true >::value_type == bool
    bool_< true >::type == bool< true >
    bool_< true >::value == true
    bool_< true >() == true
   
    int_部分
   
    int_的声明如下
   
    template< int N >
    struct int_;
   
    int_特性如下
    int_< 10 >::value_type == int;
    int_< 10 >::type == int_< 10 >;
    int_< 10 >::value == 10;
    int_< 10 >() == 10;
   
    long_部分
   
    long_的声明如下
   
    template< long N >
    struct long_;
   
    long_特性如下
    long_< -500 >::value_type == long;
    long_< -500 >::type == long_< -500 >;
    long_< -500 >::value == -500;
    long_< -500 >() == -500;
   
    size_t部分
   
    size_t的声明如下
   
    template< std::size_t N >
    struct size_t;
   
    size_t的特性如下
    size_t< 20 >::value_type == std::size_t;
    size_t< 20 >::type == size_t< 20 >;
    size_t< 20 >::value == 20;
    size_t< 20 >() == 20;
   
    integral_c部分
   
    integral_c的声明如下
    template< typename T, T N >
    struct integral_c;
   
    integral_c的特性如下
    integral_c< short, 8 >::value_type == short;
    integral_c< short, 8 >::type == integral_c< short, 8 >;
    integral_c< short, 8 >::value == 8;
    integral_c< short, 8 >() == 8;

posted on 2007-03-10 14:10 walkspeed 阅读(1948) 评论(0)  编辑 收藏 引用 所属分类: STL、Boost、范型编程

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2007年3月>
25262728123
45678910
11121314151617
18192021222324
25262728293031
1234567

常用链接

留言簿(4)

随笔分类(64)

随笔档案(58)

文章分类(3)

文章档案(3)

相册

收藏夹(9)

C++零碎

好友

搜索

  •  

积分与排名

  • 积分 - 157797
  • 排名 - 163

最新评论

阅读排行榜

评论排行榜