摘要: boost::any 是一个非常灵活的类型安全容器,可以存储任意类型的值,是实现“泛型容器”或“动态类型”的重要工具。 #include <boost/any.hpp> #include <iostream> #include <vector> #include <string> #include 阅读全文
posted @ 2021-03-06 23:59 osbreak 阅读(72) 评论(0) 推荐(0)
摘要: boost的timer类可以计算时间的流逝,可以用来测量程序的运行时间,算法的执行时间等,提供毫秒级别的时间精度,最大的时间间隔是596小时. boost::timer 和 boost::progress_timer 通常只提供 秒级或毫秒级精度,不适合高精度性能分析。 推荐使用 boost::ch 阅读全文
posted @ 2021-03-06 23:44 osbreak 阅读(73) 评论(0) 推荐(0)
摘要: #include <cstdio> #include <iostream> #include <sstream> #include <boost/date_time/gregorian/gregorian.hpp> using namespace std; using namespace boost 阅读全文
posted @ 2021-03-06 23:04 osbreak 阅读(314) 评论(0) 推荐(0)
摘要: #include <boost/algorithm/string.hpp> //转 大/小 写 boost::to_upper(s); std::cout << s << std::endl; boost::to_lower(s); std::cout << s << std::endl; //转 阅读全文
posted @ 2021-03-06 17:03 osbreak 阅读(521) 评论(0) 推荐(0)
摘要: boost::lexical_cast 是 C++ 中最优雅的类型转换工具之一,尤其适合配置解析、CLI 参数处理、日志系统等场景。 // 字符串 转 数值 try { std::string str1 = "123"; int n = boost::lexical_cast<int>(str1); 阅读全文
posted @ 2021-03-06 16:30 osbreak 阅读(140) 评论(0) 推荐(0)