1.判断路径存在,如果不存在则创建
if ( !boost::filesystem::exists(path)) {
boost::filesystem::create_directories(path) ;
}
2.格式化参数
_moveCmd = boost::format( "4,%1%,%2%,%3%,%4%,%5%,%6%," ) ;
_moveCmd % axle.a1 % axle.a2 % axle.a3 % axle.a4 % axle.a5 % axle.a6 ;
2.1切割字符串
#include <boost/format.hpp>
https://blog.youkuaiyun.com/huang_xw/article/details/8449045
3.时间
#include <boost/date_time/posix_time/posix_time.hpp>
auto t = boost::posix_time::microsec_clock::local_time() ;
std::string strTime = boost::posix_time::to_iso_string(t_now);
4.boost序列化--类似于Google Protobuff
- 可以序列化STL对象
- 可以序列化自己构造的结构-入侵时和非入侵式(与要定义的序列化模板函数有关)
https://www.ibm.com/developerworks/cn/aix/library/au-boostserialization/
5.boost lambda表达式
/*
**函数功能:打印大于1的数据
**注意:cout要接\n
*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/if.hpp>
int main()
{
std::vector<int> v;
v.push_back(1);
v.push_back(3);
v.push_back(2);
std::for_each(v.begin(), v.end(),boost::lambda::if_then(boost::lambda::_1>1,
std::cout<<boost::lambda::_1<<"\n"));
}
6.泛函数
#include <boost/function.hpp>
/*
**类似于智能指针
*/