CppCon 2018: Brian Ruth “std::basic_string: for more than just text”

preview_player
Показать описание


Lightning Talk


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

Some of these little 4-5 minute videos have been great!

nivenfres
Автор

It's not about how good std::basic_string is. It's about how lacking the C++ standard library is, alas.

MaceUA
Автор

The small buffer optimization is welcome for vector and other containers as well. Boost has small_vector but it would be appreciated if added to the std in some kind of form.

gast
Автор

This shows that (some of) the concepts behind basic_string are probably more generic and that there would be a better name for them.
But probably our thinking of what a string consists of, is too narrow.
In a literal sense a string of bits makes perfectly sense to me. But as a programmer I am used to the very strong and pretty narrow meaning :)

neur
Автор

Now I want to try the same with std::stringstream

Lttlemoi
Автор

capacity is at least size+1 for zerro terminator. In vector may be equal.

kpanat
Автор

submit this as a full talk at some conference!

TheThirdAttractor
Автор

Is it just me or is there a speck of dirt on the video that won't go away?

thevinn
Автор

random access because of contiguous memory It's not a separate advanage. It size is too big it's look disadvantage. So it's hard to find this big contiguous memory block. But access is quick.

kpanat
Автор

+=, contiguous .data(), SSO: that's a really cool 'trick'.
I wonder how gcc can't drop the useless nee/delete. Is new considered to have side effects? I thought malloc my be dropped if deemed irrelevant?

lorink
Автор

Oh god.
The problem is it's kind of hard to convey what we're doing when using std::basic_string<bool> it's kind of a hack. (That should be implemented differently)
But that's useful information. I never really thought about using std::basic_string for anything, not even a string to be honest.

LemonChieff
Автор

This requires specializing char_traits for the contained type right? Isn't it UB to add specializations to std types for non-user defined types like bool and uint64_t?

Betadel
Автор

I'm use to "upload" a text file to a std::string, which is faster and has many more features than working with a file. However, I never thought a std::basic_string could be faster/smaller (assembly) than a std::vector.
PS: by the way, is std::basic_string faster than std::string too?

MrAbrazildo
Автор

Why are they laughing? I don't get the joke

marcpanther
Автор

This is absolutely a terrible! Look into the memory for these data structures. A vector<bool> is a bit array, which is kind of cool and useful. bit_states[0] returns a proxy class (design patterns), which is why you can't Lbind to it. If you look at the actual memory that gets set, and push_back(true) x 5 gives you a 0x1f in memory (its a bit set and kind of cool). If you have a basic_string<bool> and do push_back(true) x 5 you get 0x01 0x01 0x01 0x01 0x01 0x01 in memory because it's an array of 5, 8 bit values (which is why you can Lbind to it). Not the same thing as doing a bitset. It's a huge was of space.

kevinwright
Автор

Yeah, if you want other devs who will read your code curse you, just go ahead use all stuff in the way it doesnt suppose to be used.

idldmit