<?xml version="1.0" encoding="utf-8"?> boost learn notes
boost learn notes
Documents
http://www.boost.org/doc/libs/1\_53\_0/libs/libraries.htm
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.
Further reading material
http://stlchina.huhoo.net/bin/view.pl/Main/WebSearch?search=BoostSource&scope=all&web=Main
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 (转载请注明出处)
转载于:https://www.cnblogs.com/jalenwang/archive/2013/05/07/3064233.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)