#include <iostream>
#include <string>
#include <boost/array.hpp>
//异构的容器
#include <boost/any.hpp>
#include <vector>
#include <typeinfo>
#include <algorithm>
using namespace std;
using namespace boost; void main()
{
boost::array<string, >mystr = { "","ab","","ef","" };
boost::array<string, >::iterator ib = mystr.begin();
boost::array<string, >::iterator ie = mystr.end();
for (; ib != ie; ib++)
{
cout << *ib << endl;
} //返回数组首地址
string *p = mystr.data();
cout << *p << endl;
mystr[] = "";
mystr.at() = ""; //异构容器
std::vector<boost::any> s_values;
s_values.push_back();
s_values.push_back('A');
s_values.push_back(19.8);
s_values.push_back("");
//cout << boost::any_cast<double>(s_values[2]) << endl; for_each(s_values.begin(),s_values.end(),
[](const boost::any &anydata)
{
//获取类型
const std::type_info &ti = anydata.type();
//根据类型执行相应的操作
if (ti == typeid(int))
{
cout << boost::any_cast<int>(anydata) << endl;
}
else if (ti == typeid(double))
{
cout << boost::any_cast<double>(anydata) << endl;
}
else if (ti == typeid(const char *))
{
cout << boost::any_cast<const char *>(anydata) << endl;
}
else if (ti == typeid(char))
{
cout << boost::any_cast<char>(anydata) << endl;
}
}); cin.get();
}

最新文章

  1. PHP5各个版本的新功能和新特性总结
  2. mvc导出excel 之 新
  3. poj 1556 The Doors
  4. hdu 4185 二分图匹配
  5. PHP 设计模式 笔记与总结(2)开发 PSR-0 的基础框架
  6. java线程实践记录
  7. Retrofit所有知识场景汇总
  8. 几个.net的GUI控件库
  9. C++学习笔记--Season 2
  10. C51汇编伪指令
  11. The example program of C on point
  12. nodejs抓取数据一(列表抓取)
  13. Oracle知识梳理(三)操作篇:SQL基础操作汇总
  14. 可编辑的div -&gt; 编辑框
  15. 52.tableViewCell重用机制避免重复显示问题
  16. Java之List排序功能举例
  17. 将BAT文件注册为服务的方法
  18. 安装deb包解决依赖问题
  19. turntable
  20. xpath教程二 ---- 通过ID和Class检索

热门文章

  1. 11. Container With Most Water[M]盛最多水的容器
  2. SQL语句之Insert
  3. Vue中问题总结 与未解决问题总结
  4. P3376 【模板】网络最大流(70)
  5. animate.css引入实现动画效果
  6. WebView简单用法
  7. Linux 搭建互信后,仍需要密码验证
  8. firefox工具
  9. HDU 2199 Can you solve this equation?【二分查找】
  10. php基础------将二维数组转三维数组