摘要:
<boost/foreach.hpp> 提供两个宏:BOOST_FOREACH 和 BOOST_REVERSE_FOREACH#include <string>#include <boost/foreach.hpp>#include <boost/assign.hpp>#include <boost/typeof/typeof.hpp>int main(){ std::vector<int> vect = boost::assign::list_of(1)(2)(3); BOOST_FOREACH(int x,vect) 阅读全文
摘要:
<boost/array.hpp>:包装内建数组,为其提供标准STL接口,如begin()、front()等,速度性能上与原始数组相差无几。#include <iostream>#include <boost/array.hpp>#include <boost/typeof/typeof.hpp>int main(){ boost::array<int,10> arr; //一个长度为10的int数组,或 boost::array<int,3> arr = {1,2,3} arr[0] = 1; arr.back() = 阅读全文
摘要:
当定义了宏 BOOST_ENABLE_ASSERT_HANDLER 后,使用 BOOST_ASSERT() 断言失败后,会调用 boost::assertion_failed() 函数,该函数声明在 boost 名字空间内,但特意被设计为没有实现。#include <iostream>#include <boost/format.hpp>namespace boost{ void assertion_failed(char const* expr,char const * function,char const* file,long line) { boost::fo. 阅读全文