1

For some reason, I cannot get ptr_list to insert elements.

boost::ptr_list<int> somelist;
int *someint = new int(123);
int *someint2 = new int(456);
somelist.push_back(someint);
boost:: ptr_list<int>::iterator i = somelist.begin();

somelist.insert(i,someint2);

Any help, please?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Andrew
  • 2,309
  • 4
  • 27
  • 42
  • You snippet compiles fine for me. What's the error message? – avakar Aug 16 '09 at 09:20
  • could you, please, tell what headers did you include? Could not find a match for 'boost::ptr_sequence_adapter >,boost::heap_clone_allocator>::insert(boost::void_ptr_iterator<_STL::_List_iterator >,int>,int *)' – Andrew Aug 16 '09 at 09:35
  • well, I guess it is specific problem of an old compiler I use (borland c++ builder 6). Downloading right now a new version to check if it solves my problem. – Andrew Aug 16 '09 at 09:45
  • I've included `boost/ptr_container/ptr_list.hpp`. – avakar Aug 16 '09 at 10:00
  • 1
    You should probably write the solution as an answer and accept it, so that the question doesn't remain unanswered. It would be wasted work for people looking for unanswered questions. – Sahas Aug 16 '09 at 17:15

1 Answers1

2

Some update. After spending another 24 hours on this, I figured out that Borland C++ Builder 6 (very old one 2002) is more compatible with boost 1.39 than a brand new C++ Builder 2009.
But neither of them seem to like pointer containers.

Right now I regret that I did not start this project in MSVC but this is what I have.

So if anyone knows how to use pointer containers with C++ Builder, please, share this information. For me this question is still unresolved.

Switched back to std::list<boost::shared_pointer>

Andrew
  • 2,309
  • 4
  • 27
  • 42
  • some update. Newest version of boost in the SVN trunk seems to have a lot of fixes for Borland and gives to access to more components but still errors with pointer containers. – Andrew Aug 20 '09 at 01:19