In the same vein, more of it should be noexcept - why aren't empty() and size() ?
empty() and size() not being noexcept is more of an oversight on our part. As for why more of the member functions aren't noexcept, they have the same exception specifications as those of their counterparts in std::string. That being said, although they do call "dangerous" operations like Traits::length that are not noexcept, such functions don't throw (at least for std::char_traits), so its difficult to specify as noexcept since Traits could also be a user defined type.
You can add a specialisation for size 0 that turns it into an empty struct.
Certainly, it would be fairly trivial to do so.
I suggested changing this to the minimum size needed to store values 0 to N in the previous email discussion, but that hasn't been implemented.
Sure, that's extremely trivial to do, and seems like a great idea.
On Tue, Nov 26, 2019 at 7:25 PM Peter Dimov via Boost
Gavin Lambert wrote:
On 27/11/2019 06:46, Peter Dimov wrote:
Vinnie Falco wrote:
In which use-cases do you anticipate the need for a constexpr static_string?
When manipulating strings at compile time? Such as s1 += s2?
Wouldn't that use case be better served with an immutable string and operator+?
Not in general.
constexpr string_view f( int x );
constexpr auto g( int n ) { fixed_string<512> s;
for( int i = 0; i < n; ++i ) { s += f( i ); }
return s; }
You can rewrite this specific example using recursion but in general, it'd be painful and unreadable.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost