zoukankan      html  css  js  c++  java
  • boost pointer container

    1. boost::ptr_vector

    #include <boost/ptr_container/ptr_vector.hpp>
    #include <iostream>
    
    int main() {
      boost::ptr_vector<int> v;
      v.push_back(new int(1));
      v.push_back(new int(2));
      std::cout << v.back() << std::endl;
      return 0;
    }

    boost::ptr_vector knows that it stores dynamically allocated objects, member functions like back() return a reference to a dynamically allocated object and not a pointer. Thus, the example writes 2 to standard output.

    2. boost:ptr_set 有顺序的容器

    #include <boost/ptr_container/ptr_set.hpp>
    #include <iostream>
    
    int main() {
      boost::ptr_set<int> s;
      s.insert(new int(2));
      s.insert(new int(1));
      std::cout << *s.begin() << std::endl;
      return 0;
    }

    输出: 1

    3. additional containers include boost::ptr_deque, boost::ptr_list, boost::ptr_map, boost::ptr_unordered_set, boost::ptr_unordered_map

  • 相关阅读:
    ACM-ICPC 2018 南京赛区网络预赛 J.Sum
    汉诺塔
    汉诺塔
    D
    D
    数学小定理
    数学小定理
    Python index()方法
    Python endswith()方法
    Python encode()方法
  • 原文地址:https://www.cnblogs.com/sssblog/p/10945320.html
Copyright © 2011-2022 走看看