Questions tagged [boost-ptr-container]

Boost.Pointer Container is a C++ library that provides containers for holding heap-allocated objects in an exception-safe manner and with minimal overhead. The aim of the library is in particular to make OO programming easier in C++ by establishing a standard set of classes, methods and designs for dealing with OO specific problems.

Boost.Pointer Container is a C++ library that provides containers for holding heap-allocated objects in an exception-safe manner and with minimal overhead. The aim of the library is in particular to make OO programming easier in C++ by establishing a standard set of classes, methods and designs for dealing with OO specific problems.

31 questions
19
votes
2 answers

stl container with std::unique_ptr's vs boost::ptr_container

With c++11 out there, I was asking myself if there is a replacement of the boost::ptr_containers in c++11. I know I can use e.g. a std::vector >, but I'm not sure if this is a complete replacement. What is the recommended way of…
P3trus
  • 6,747
  • 8
  • 40
  • 54
12
votes
4 answers

Is there an easy way to make `boost::ptr_vector` more debugger friendly in Visual Studio?

I'm considering using boost::ptr_container as a result of the responses from this question. My biggest problem with the library is that I cannot view the contents of the collection in the debugger, because the MSVC debugger doesn't recognize it, and…
8
votes
2 answers

std::reverse on boost::ptr_vector slices objects?

Let Base and Derived be classes with data members: class Base { public: Base(int i):f(i) { } virtual void print() { cout << "base " << f << endl; } int f; }; class Derived: public Base { public: Derived(int i):Base(0),g(i) { } …
Philipp
  • 957
  • 1
  • 6
  • 20
6
votes
1 answer

Measuring performance of vector on VS2013?

TL;DR Is the optimizer of VS2013 confused or are my measurements wrong or does the global dummy in fact need to be volatile to make the test valid or ____ ? Disclaimer: This is mostly out of "academic" interest, I would not expect the differences I…
Martin Ba
  • 37,187
  • 33
  • 183
  • 337
5
votes
1 answer

Mapping object that contains a ptr_map of abstract base classes

I have a boost::ptr_map which stores abstract base class (e.g. VectorWrapperBase) as values and this allows me to map strings to vectors of different types. boost::ptr_map memory_map; //... memory_map.insert(str_key,…
Shawn Chin
  • 84,080
  • 19
  • 162
  • 191
4
votes
3 answers

STL algorithm to delete all the objects in a container?

Is there a STL utility/algorithm to do delete *the_object_iterator; on all the objects? So that I can clear() safely? The STL container is a set and the objects are pointers to C++ classes created with new. Boost seems to be the best solution. My…
unixman83
  • 9,421
  • 10
  • 68
  • 102
4
votes
1 answer

Storing pointers to const objects in boost::ptr_unordered_map

I can't seem to make boost::ptr_unordered_map work - the underlying implementation looks like it's casting things to a void*. Do I just have to bite the bullet and make my methods that wrap access to this do a const_cast
Alastair Maw
  • 5,373
  • 1
  • 38
  • 50
4
votes
1 answer

boost ptr_container library isn't installed after compilation from source

I have updated boost library from previous 1.54 (svn source) to 1.57 (git source). Although I used the same ./b2 params, destination directory doesn't contain ptr_container library. Directory with cloned repository correctly contains ptr_container…
Ludek Vodicka
  • 1,610
  • 1
  • 18
  • 33
3
votes
0 answers

Moving a boost::ptr_vector

Given a type which is non-copyable but movable, I am trying to construct a boost::ptr_vector of this type and return it from a function. I am using Visual Studio 2013. struct NonCopyableButMovable { using this_type = NonCopyableButMovable; …
3
votes
1 answer

ptr_map inserting

I have some predefined type which inherits boost::noncopyable (so I have to store the pointer at these objects). I use a boost::ptr_map. As I know, the second argument in it is already a pointer. So, the code: ptr_map
Max Frai
  • 61,946
  • 78
  • 197
  • 306
3
votes
1 answer

Benefits of using lower_bound to search a map before insertion. Equivalent for ptr_map?

While looking for an efficient approach to insert to a map only if the key does not exist, I came across this approach: MapType::iterator lb = mymap.lower_bound(k); if(lb != mymap.end() && !(mymap.key_comp()(k, lb->first))) { // key exists.…
Shawn Chin
  • 84,080
  • 19
  • 162
  • 191
2
votes
1 answer

Forward-declared class in boost::ptr_list

for a small science project I set up a Simulation class which holds all simulated Objects in a ptr_list. Because I need to have fast access to all Particles I added an additional ptr_list. Now boost complains, because it doesn't like forward…
2
votes
1 answer

boost ptr_container leak on 'release'?

I'm assuming that an object that's released from a ptr_set is leaked if it's not manually deleted. However, the test program below only shows 2 leaks in valgrind (from lines 9/13), and no leak for line 12. Have I misunderstood release, or is…
EML
  • 1,025
  • 2
  • 9
  • 16
2
votes
0 answers

boost::ptr_vector segmentation fault on delete (munmap_chunk())

I am using a boost::ptr_vector to contain a list of class objects. I add the objects to the ptr_vector in this way: parent_ptrvector.push_back(new PlanVertex(-1,-1,-1)); I only add objects once, when the class containing the ptr_vector is…
2
votes
0 answers

Puzzling segfault when inserting to ptr_map

I have been pulling my hair for a few hours trying to understand a puzzling segfault. The exact same code works in my object constructor but not in the object's method where it's supposed to be: I get a segfault at run time. Hopefully, I have not…
augustin
  • 14,373
  • 13
  • 66
  • 79
1
2 3