From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2019-09-10 13:15:24
Vinnie Falco wrote:
> Beast has static_string which someone has asked to be move, is there
> any interest in moving this to Boost.Container?
Having this outside Beast would certainly make it more
I have been making a lot of use of boost::container::small_vector
and boost::container::static_vector recently. A first thought is
that one could wrap those in a vector-to-string adaptor to get
small and static strings (and I have a string_facade class
template that does much of that). I think it would be useful to
have a small_string implemented like this, but it's not the best
solution for static_string.
I note that the current Beast static_string stores a size_t and
an array of chars. This is the right approach; it makes it
trivially-copyable. But if small size is an aim (and I think it
should be), we can do better; when N < 256, use a uint8_t for the
size. In fact, use boost::integer::uint_t< log2<N> >::least and
get an optimal type for the size.
I have just been looking at an old FixedString class that I wrote
a few years ago, which is very much like the Beast static_string.
The only other feature I added was an on-overflow policy template
parameter, allowing you to throw, assert, truncate or UB on
overflow. I don't know if I ever really used that.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk