Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: pitfalls of...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 9529 of 9807
Post > Topic >>

Re: pitfalls of string for binary data

by Marco Manfredini <ok_nospam_ok@[EMAIL PROTECTED] > Apr 23, 2008 at 02:13 PM

Brendan wrote:

> At a prior job, people were using std::string to hold arbitrary binary
> data, as opposed to vector<char>. I've seen a few people in this group
> poopoo that notion, and I'd like to find out what they think the
> pitfalls, if any, of using string to hold binary data are. I ask,
> because otherwise the code base was pretty high quality, and string
> does offer a number of extra search based member functions that vector
> does not.

The standard asserts no complexity bounds to the string operations
(exception: swap). char_traits<> has bounds given, but that isn't
helping here. You may end up with an implementation which has, for
example, very fast inserts, but slow replacements or the other way
round.

> 
> Additionally, is there any strong reason to use unsigned char as
> opposed to char to hold binary data where the high order bit might be
> set? Again, in practice I've mostly seen char used.

predictable sorting order maybe or defined behavior on overflow?

-- 
IYesNo yes=YesNoFactory.getFactoryInstance().YES;
yes.getDescription().equals(array[0].toUpperCase());

      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 4 Posts in Topic:
pitfalls of string for binary data
Brendan <catphive@[EMA  2008-04-22 11:43:17 
Re: pitfalls of string for binary data
Lance Diduck <lancedid  2008-04-22 15:19:17 
Re: pitfalls of string for binary data
"Charles" <e  2008-04-22 22:27:13 
Re: pitfalls of string for binary data
Marco Manfredini <ok_n  2008-04-23 14:13:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 19 19:56:04 CDT 2008.