On 3/12/2019 07:02, Zach Laine wrote:
On Mon, Dec 2, 2019 at 11:48 AM Peter Dimov wrote:
Zach Laine wrote:
I don't find it natural that a type whose size is statically known and a type whose size is not statically known have the same relationship to user code (preconditions, use of UB vs. exceptions, etc.).
But the size of the proposed fixed_string isn't statically known. Its capacity is.
Right, thanks. I wrote "size" when I meant "capacity". I think the point remains the same, however. I know statically how much room I have in which to operate, as opposed to having a runtime-variable amount of room.
But given fixed_string<N> and fixed_string<M>, there is no way to
determine at compile time whether direct concatenation is safe or will
overflow, even presuming you are appending to the larger of the two.
The only way to guarantee at compile time that a concatenation is not at
risk of overflow is to first copy to a fixed_string