Boost logo

Boost :

From: Jan Gaspar (jano_gaspar_at_[hidden])
Date: 2008-05-15 09:29:39

OK, will see what can I do with the 1.35.1. release. Btw on the 4th line I don't see a problem to explicitly set the capacity like this: circular_buffer<char> buffer(0); // nothing will be allocated ----- Original Message ---- From: Dean Michael Berris <mikhailberis_at_[hidden]> To: boost_at_[hidden] Sent: Thursday, 15 May, 2008 2:04:58 PM Subject: Re: [boost] [circular_buffer] default constructor usually throws std::bad_alloc On Thu, May 15, 2008 at 7:48 PM, Jan Gaspar <jano_gaspar_at_[hidden]> wrote: > This was an intended behaviour (to allocate the maximum capacity). The reason behind this was to comply with other STL containers. I admin the decision was not the best one. I will change this as you propose but in the Boost version 1.36. For now just use the constructor with the explicit capacity paramater or override the allocator's max_size() to return some sensible value. > Actually, this is going to be really hard to do especially if you are expecting the buffer from another source and just need a default constructed "receiver" to get it: map<string, circular_buffer<char> > input_buffers; input_buffers.insert(std::make_pair("cin", circular_buffer<char>(1000))); input_buffers.insert(std::make_pair("net", circular_buffer<char>(2048))); circular_buffer<char> buffer; // this will throw string source; cin >> source; if (input_buffers.find(source) != input_buffers.end()) { buffer = input_buffers.find(source)->second; }; With the current implementation, you may not be able to get past the default constructed buffer, and if you did set some capacity, you'd be wasting memory. Shouldn't the change make it to Boost 1.35.1? :-D It's a really trivial fix for the constructor, but I haven't looked at how it will affect the other areas of the code. Thanks for the quick response! :) -- Dean Michael C. Berris Software Engineer, Friendster, Inc. [] [mikhailberis_at_[hidden]] [+63 928 7291459] [+1 408 4049523] _______________________________________________ Unsubscribe & other changes: __________________________________________________________ Sent from Yahoo! Mail. A Smarter Email

Boost list run by bdawes at, gregod at, cpdaniel at, john at