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
2
votes
1 answer

Clone allocators, and polymorphism in boost::ptr_container

For my current project I am using a boost::ptr_vector to hold Objects polymorphically, and it was all working fine until one of my builds VS2010 throw that it could not clone the object so I went, and looked up cloning, and implemented the…
gardian06
  • 1,496
  • 3
  • 20
  • 34
1
vote
1 answer

Differences between std::set and boost::ptr_set?

I've changed some code to convert a std::set to a boost::ptr_set. However, the code doesn't compile; the problem is that I'm assuming that the return value from a ptr_set insert is the same as a set insert (a pair). After an hour on…
EML
  • 1,025
  • 2
  • 9
  • 16
1
vote
1 answer

How do I delete from a boost::ptr_set when I know the pointer I inserted?

How do I delete from a boost::ptr_set when I know the pointer I inserted? (I have a this pointer to the inserted class object). Here is a contrived example to show what I am trying to do: boost::ptr_set
unixman83
  • 9,421
  • 10
  • 68
  • 102
1
vote
2 answers

Getting Pointer or Reference to mapped_type from Arbitrary Map

Edit: I've found and written up a solution to my problem but I've left the question unanswered since my solution may still not be ideal. I'm writing a small library designed to perform routines on maps of maps, but I'm having trouble designing a set…
void-pointer
  • 14,247
  • 11
  • 43
  • 61
1
vote
2 answers

C++ Befriending boost::ptr_map / boost::checked_delete fails

I want to use a boost::ptr_map inside a specific class which stores instances of itself. However, please consider the following example: #include #include class foo { friend void…
0xbadf00d
  • 17,405
  • 15
  • 67
  • 107
1
vote
1 answer

How to safely fill Boosts's pointer containers?

The first example for Boost Pointer Container adds a raw pointer to the structure: class zoo { boost::ptr_vector the_animals; public: void add_animal( animal* a ) { the_animals.push_back( a ); } }; But what if…
1
vote
1 answer

Increasing Speed of Destruction

I have an application that creates thousands of small objects (upwards of 500,000). There is an object factory that allocates these objects on the heap. The problem that I'm running into is that when the object that holds these smaller object goes…
burtmacklin16
  • 715
  • 2
  • 13
  • 31
1
vote
1 answer

When ptr_vector iterators are invalidated

Is it possible that inserting and/or erasing elements can invalidate iterators to existing elements. Thank you.
pic11
  • 14,267
  • 21
  • 83
  • 119
1
vote
1 answer

Return value goes bad with std::map and boost::ptr_map templates and inheritance

At the company I work at we created a class called 'RestrictedMap'. This provides the same interface as a regular std::map but will not allow you to use the [] operator. Some other functions have been provided to work with the class comfortably.…
Tekar
  • 105
  • 2
  • 8
1
vote
3 answers

ptr_vector is not freed properly

I am trying to use a ptr_vector to store some pointers, but I get an error as soon as my main method. Here is my code: int main(void) { boost::ptr_vector temp; string s1 = "hi"; string s2 = "hello"; temp.push_back(&s1); …
Qman
  • 377
  • 1
  • 4
  • 14
1
vote
3 answers

fast way partially sort objects

I have a routine in which I define a bunch of objects (around 20), call them Jet, which have a defined < that I'm using to sort them. After they are sorted, I take the lowest two. What is a fast way to do this? The options I've thought of so far:…
Shep
  • 7,990
  • 8
  • 49
  • 71
1
vote
0 answers

boost::ptr_map<> and _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) assertion failures

first question on stackoverflow, was hoping to get some help with this issue. If you take a look at the following EffectManager class, I am getting an assertion failure on _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) when an effectmanager instance is…
Faris M
  • 540
  • 4
  • 10
0
votes
1 answer

Boost Pointer Container - can't store class as the key for ptr_map

I've been trying to play around with the Boost Pointer Container library and utilize their tutorial examples to get a feel for the library. Maybe I'm missing something, but I can't seem to store a simple class that I've defined as the key to…
0
votes
1 answer

glibc detected : free(): invalid pointer: with simple boost::ptr_map example

I know there are scores of questions with "* glibc detected * free(): invalid pointer", but the following is a minimalist example with boost::ptr_map: #include #include int main() { …
augustin
  • 14,373
  • 13
  • 66
  • 79
0
votes
1 answer

Difference between std::unordered_map < K, boost::ptr_deque < T > >'s operator[] (K const &) and emplace

#include #include #include #include #include struct T { T() = default; T(T const &) = delete; T & operator = (T const &) = delete; T(T &&) = default; …
zrb
  • 851
  • 7
  • 16