
Hello there, i am new here and i just want to say "hi". so, i'm using boost almost a year now, usually i just used the array component. latley i wanted to implement the circular_buffer. i've defined it in a class after the private-modifier like this: boost::circular_buffer<std::string> textBuffer(10); (as take from the documentation) but my compiler on minGW will throw an error. so, i guess i got something wrong in declaring a string-textbuffer with the lenght of 10?! in the boost-docs there is following example: boost::circular_buffer<int> cb(3); help is appreciated, best would be a working example and a little hint which information is may have missed. greetings tony

news.gmane.org wrote on Tuesday, March 27, 2012 8:42 PM
i've defined it in a class after the private-modifier like this:
boost::circular_buffer<std::string> textBuffer(10);
(as take from the documentation)
but my compiler on minGW will throw an error. so, i guess i got something wrong in declaring a string-textbuffer with the lenght of 10?!
in the boost-docs there is following example: boost::circular_buffer<int> cb(3);
Usually you can't specify the constructor arguments at the point of declaration of a class member. Does something like this work? Class A { A() : textBuffer(10) {} boost::circular_buffer<std::string> textBuffer; }; ---------------------------------------------------------------------- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses. References to "Sender" are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing.

hey, this sollution compiles. due to an error i dont knot if my last message has been sent so here a shot overview; when debugging, i got some errors. do i use the circurlar buffer wrong? here is an short extraction of my implementation: class Stringbuffer { public: Stringbuffer() : buffer(10) {} boost::circular_buffer<std::string> buffer; }; in another class: class ConsoleText { public: // some declarations private: Stringbuffer *textBuffer; } then, on the constructor: ConsoleText::ConsoleText() { textBuffer = new Stringbuffer(); } during the runtime i do this: void ConsoleText::GetConsoleMessage(std::string message) { textBuffer->buffer.push_front(message); } void ConsoleText::GetConsoleMessage(std::string message, int num) { message += " : "; message += toString(num); textBuffer->buffer.push_front(message); } void ConsoleText::FormatOutput() { outPutText = ""; for (int i = 0; i < textBuffer->buffer.size(); i++) { outPutText += textBuffer->buffer.front(); outPutText += "\n"; } } now, as i've got from the documentation, the last entry of the buffer will be overwritten, which just fits into my requirenments. on this call: textBuffer->buffer.push_front(message); i'll get a segmantion fault, which is an indicator of that textBuffer wasn't instantiated well. but where's the problem, i don't see it. sorry - any ideas? Am 3/28/2012 1:36 PM, schrieb Nelson, Erik - 2:
news.gmane.org wrote on Tuesday, March 27, 2012 8:42 PM
i've defined it in a class after the private-modifier like this:
boost::circular_buffer<std::string> textBuffer(10);
(as take from the documentation)
but my compiler on minGW will throw an error. so, i guess i got something wrong in declaring a string-textbuffer with the lenght of 10?!
in the boost-docs there is following example: boost::circular_buffer<int> cb(3);
Usually you can't specify the constructor arguments at the point of declaration of a class member. Does something like this work?
Class A { A() : textBuffer(10) {} boost::circular_buffer<std::string> textBuffer; };
---------------------------------------------------------------------- This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Sender. Subject to applicable law, Sender may intercept, monitor, review and retain e-communications (EC) traveling through its networks/systems and may produce any such EC to regulators, law enforcement, in litigation and as required by law. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or free of errors or viruses.
References to "Sender" are references to any subsidiary of Bank of America Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this EC may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you consent to the foregoing.
_______________________________________________ Unsubscribe& other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

news.gmane.org wrote:
when debugging, i got some errors. do i use the circurlar buffer wrong?
These posts are not on topic. You're hitting many basic C++ errors and this list is not the place to learn the language. Refer to http://www.boost.org/community/policy.html for details.
void ConsoleText::FormatOutput() { outPutText = ""; for (int i = 0; i < textBuffer->buffer.size(); i++) { outPutText += textBuffer->buffer.front(); outPutText += "\n"; } }
In this case, you're never advancing through textBuffer->buffer's elements but rather calling front() repeatedly. You need to call pop_front() to move to the next element. I have no idea what outPutText is, but it may be misbehaving when you make it too large.
on this call: textBuffer->buffer.push_front(message);
i'll get a segmantion fault, which is an indicator of that textBuffer wasn't instantiated well.
For that to segfault, I suspect your memory is trashed. Is textBuffer still a valid pointer in that case? Have you actually used a debugger? Please consider posting to comp.lang.c++.moderated or somewhere else to work on such problems. _____ Rob Stewart robert.stewart@sig.com Software Engineer using std::disclaimer; Dev Tools & Components Susquehanna International Group, LLP http://www.sig.com ________________________________ IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

thank you! i'll consider to have a more look into the c++ language and throwing my questions in comp.lang.c++ on the other hand i have to admit that i have confused serveral times myself, which is, just another problem ^^ Am 3/28/2012 9:48 PM, schrieb Stewart, Robert:
news.gmane.org wrote:
when debugging, i got some errors. do i use the circurlar buffer wrong?
These posts are not on topic. You're hitting many basic C++ errors and this list is not the place to learn the language. Refer to http://www.boost.org/community/policy.html for details.
void ConsoleText::FormatOutput() { outPutText = ""; for (int i = 0; i< textBuffer->buffer.size(); i++) { outPutText += textBuffer->buffer.front(); outPutText += "\n"; } }
In this case, you're never advancing through textBuffer->buffer's elements but rather calling front() repeatedly. You need to call pop_front() to move to the next element. I have no idea what outPutText is, but it may be misbehaving when you make it too large.
on this call: textBuffer->buffer.push_front(message);
i'll get a segmantion fault, which is an indicator of that textBuffer wasn't instantiated well.
For that to segfault, I suspect your memory is trashed. Is textBuffer still a valid pointer in that case? Have you actually used a debugger?
Please consider posting to comp.lang.c++.moderated or somewhere else to work on such problems.
_____ Rob Stewart robert.stewart@sig.com Software Engineer using std::disclaimer; Dev Tools& Components Susquehanna International Group, LLP http://www.sig.com
________________________________
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of vi ruses.
_______________________________________________ Unsubscribe& other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (3)
-
Nelson, Erik - 2
-
news.gmane.org
-
Stewart, Robert