Boost Container provides additional advantages:

(1) The interface of the containers resemble those of the containers in the C++11 standard library.

(2) With boost::container::slist or boost::container::stable_vector, Boost container offers containers the standard library doesn't provide.

(3) The implementation is platform independent.

(4) The containers from Boost Container support incomplete types and can be used to define recursive containers.

#include <boost/container/stable_vector.hpp>
#include <iostream> using namespace boost::container; int main() {
stable_vector<int> v(, );
int& i = v[];
v.erase(v.begin());
std::cout << i << std::endl;
return ;
}

输出:1

boost::container::stable_vector behaves similarly to std::vector, except that if boost::container::stable_vector is changed, all iterators and references to existing elements remain valid. This is possible because elements aren't stored contiguously in boost::container::stable_vector. It is still possible to access elements with an index even though elements are not stored next to each other in memory.

Additional containers provided by Boost Container are boost::container::flat_set, boost::container::flat_map, boost::container_slist, boost::container::static_vector.

boost::container::static_vector stores elements like std::array directly in the container. Like std::array, the container has a constant capacity. The capacity is conastant, but can be changed with resize(). push_back() doesn't change the capacity, throws an exception of type std::bad_alloc.

boost container的更多相关文章

  1. boost库使用:vs2013下boost::container::vector编译出错解决

    boost版本:boost_1_55_0 bug报告地址 https://svn.boost.org/trac/boost/ticket/9332 出错信息 has_member_function_c ...

  2. Google C++ Style Guide

    Background C++ is one of the main development languages used by many of Google's open-source project ...

  3. zz A list of open source C++ libraries

    A list of open source C++ libraries < cpp‎ | links http://en.cppreference.com/w/cpp/links/libs Th ...

  4. klayge 4.2.0 编译vc9

    CMake Error at CMakeLists.txt:442 (ADD_PRECOMPILED_HEADER): Unknown CMake command "ADD_PRECOMPI ...

  5. Cppcheck 1.54 C/C++静态代码分析工具

    Cppcheck是一个C/C++代码分析工具,只检测那些编译器通常无法检测到的bug类型.   官方上建议让编译器提供尽量多的警告提示:1.使用Visual C++的话,应使用警告等级4 2.使用GC ...

  6. 【精解】EOS标准货币体系与源码实现分析

    EOS智能合约中包含一个exchange合约,它支持用户创建一笔交易,是任何两个基本货币类型之间的交易.这个合约的作用是跨不同币种(都是EOS上的标准货币类型)的,通过各自与EOS主链价值进行锚定,然 ...

  7. Google C++ 代码规范

    Google C++ Style Guide   Table of Contents Header Files Self-contained Headers The #define Guard For ...

  8. c++开发规范

    目录 1. 头文件 1.1. Self-contained 头文件 1.2. #define 保护 1.3. 前置声明 1.4. 内联函数 1.5. #include 的路径及顺序 2. 作用域 2. ...

  9. EOS 修改文件名称与文件夹名称

    最近有一个需求,需要修改EOS名称,将所有文件里面的EOS改为UOS,文件夹名称也需要修改,然后重新构建项目,于是写了一个小程序进行修改.如果有相同项目类似的修改,可以在下面这个程序稍做修改就可以了. ...

随机推荐

  1. FCC 成都社区·前端周刊 第 10 期

    1. Node.js 10 正式发布 在过去的一周,Node.js 10.0.0 正式发布,带来大量改进和修复.这是自 Node.js Foundation 开展以来的第七个主要版本,并将在 2018 ...

  2. Linux shell 归纳之 ~/. 是什么意思

    假设用户名目录是:/home/test ~> cat ~/.profile ~ 是代表用户名目录/home/test/ .是代表隐藏文件, profile 就是home/test目录下的隐藏文件

  3. windows下源码安装调试postgresql

    环境:windows 10 postgresql版本:postgresql-9.6.5 使用工具:vs2017社区版 辅助工具:perl.diff.flex.bison 相关工具下载地址: perl下 ...

  4. Socket编程半双工

    服务器 package com.test; import java.io.IOException; import java.net.*; import java.io.*; public class ...

  5. [Bzoj1051][HAOI2006]受欢迎的牛(tarjan)

    题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1051 由题意可知,被所有牛仰慕的牛之间也互相仰慕,则最后的答案一定是唯一的强连通分量,如 ...

  6. 数据库之Query Builder

    Yii的查询构造器提供了一个用面向对象的方法来构造SQL语句.他让开发人员可以用类的方法,属性来作为SQL语句的一部分.然后把不同部分组装到一个正确的SQL语句中,调用DAO的方法来执行.下面的例子演 ...

  7. php页面出现空白解决方法

    查询php程序使用内存情况 $size = memory_get_usage(); file_put_contents("d:/data.php", var_export($siz ...

  8. 查找idt table 所對應的page table in Linux

    #include <linux/kernel.h> #include <linux/module.h> #include <linux/types.h> #incl ...

  9. CodeChef Count Substrings

    Count Substrings   Problem code: CSUB   Submit All Submissions   All submissions for this problem ar ...

  10. Go语言_方法和接口

    方法和接口 本节课包含了方法和接口,可以用这种构造来定义对象及其行为. Go 作者组编写,Go-zh 小组翻译. https://tour.go-zh.org/methods/1 方法 Go 没有类. ...