• 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 (转载请注明出处)

  • 相关阅读:
    mate9进水黑屏维修
    无重复最长字串
    布偶猫
    移除失效的打开方式
    NAO机器人实验日常
    226. 翻转二叉树
    20.有效括号
    GraphX中的图构造器
    Spark读取Hive数据的方式
    GraphX中顶点和边的RDD操作
  • 原文地址:https://www.cnblogs.com/jalenwang/p/3064233.html
Copyright © 2020-2023  润新知