boost库中mpl中的Data_Types

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;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值