zoukankan      html  css  js  c++  java
  • boost learn notes

    boost learn notes

    boost learn notes

    Get Started

    example.cpp

    #include <boost/lambda/lambda.hpp>
    #include <iostream>
    #include <iterator>
    #include <algorithm>
    
    int main()
    {
        using namespace boost::lambda;
        typedef std::istream_iterator<int> in;
    
        std::for_each(
            in(std::cin), in(), std::cout << (_1 * 3) << " " );
    }
    
    

    Build it

    cl /EHsc /I <path-to-boost> example.cpp

    Run initcl if cl is not available.

    Run it

    echo 1 2 3 | example

    Further reading material

    boost::any

    以单个对象接受所有型别的数据,以any_cast取出数据。

    template<typename ValueType>
    ValueType * any_cast(any * operand)
    {
            return operand && operand->type() == typeid(ValueType) ? &static_cast<any::holder<ValueType> *>(operand->content)->held:0;
    }
    

    boost::type_traits

    type traits的动机是分派,已实现函数重载。

    is_array的简化版

    template<bool b_>  
    struct bool_type{  
        static const bool value = b_;  
    };  
      
    template<bool b_>  
    const bool bool_type<b_>::value;  
      
    template<typename T>  
    struct is_array : bool_type<false>{  
    };  
      
    template<typename T>  
    struct is_array<T[]>: bool_type<true>{  
    };  
      
    template<typename T, unsigned int N>  
    struct is_array<T[N]> : bool_type<true>{  
    };  
      
      
      
    int main()  
    {  
        bool is_1 = is_array<int[]>::value;  
        bool is_2 = is_array<int[5]>::value;  
        bool is_3 = is_array<int>::value;  
    } 
    

    Post by: Jalen Wang (转载请注明出处)

  • 相关阅读:
    使用Sed抽取MySQL安装文档的目录及行号
    [MySQL]关于Com_状态
    [译]理解对象存储如何工作
    [译]OpenStack Object Storage Monitoring
    通过设置swift中container的ACL提供匿名访问及用户授权读取服务
    使用swift命令遭遇503错误
    swift-get-nodes简单使用
    修改虚拟硬盘的大小
    php-fpm重启
    Windows学习"Network Analysis in Python"
  • 原文地址:https://www.cnblogs.com/jalenwang/p/3064233.html
Copyright © 2011-2022 走看看