
on Sat Oct 15 2011, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
Dave Abrahams wrote:
on Sat Oct 15 2011, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
What are the "proper" uses for it?
It sounds like you're asking me to prove something for which we both know there's no proof.
Not really. As I already said in the other message, doing more push_backs than a compile-time constant size is a logic error only when the number of push_backs is a compile-time constant as well. So, it follows that it is only proper to use static_vector when the number of push_backs is known at compile time.
Or when you have a fallback response (like dynamic allocation). But the right place to put that fallback response is where capacity is exceeded, not somewhere outside after an exception is thrown.
So I was wondering what some of these (nontrivial and variable size) uses are.
As an example, a case in which 99.4% of the time the number of push_backs doesn't exceed capacity is a legitimate use, but it's not a logic error, and quite fits the mantra that "exceptions should be exceptional".
I never liked that mantra anyhow, but you're right that it is a legitimate use *if* your program can handle a particular step failing .6% of the time. -- Dave Abrahams BoostPro Computing http://www.boostpro.com