$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] Interest in StaticVector - fixed capacity vector
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2011-10-15 05:26:41
Dave Abrahams wrote:
>> What are the metrics by which you define an exception as both
>> incorrect and/or worse? What is lost by using an exception? Does it
>> break a convention, reduce performance, break purity, or upend general
>> happiness?
>
> All answered already in my first posting in the thread.
>
Exceptions shouldn't be used to report programmer's errors. Putting an 
element outside the array is a programmer's error as e.g. dereferencing 
iterator pointing somwhere outside some range. Programmer can prevent 
this and therefore he should. He should check ranges or equality to the 
end iterator. If the exception is thrown it don't change anything, the 
programmer must fix the code. Asserts should be used in this case.
But in the case of bad memory allocation he probably can't do anything 
in this part of code. Maby he allocates to much somewhere in the other 
part of the code? But, maby some other application allocates hudge 
amount of memory or the system is broken etc. This is something unexpected.
You want to mimic std::vector behaviour with bad_alloc exceptions and I 
understand that. So maby it's a good idea to change the name from 
static_vector to e.g. pushable_array or other XXX_array and it will be 
clear that this container is similar to the array not the vector and 
will not throw any bad_alloc exception because it don't even allocates 
the memory.
Regards,
Adam