Subject: Re: [ublas] fixed size vector in boost::numeric::ublas?
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2010-07-23 15:51:22
Vardan Akopian <vakopian <at> gmail.com> writes:
> ), defines the resize() method. Moreover it has a post condition
> v.size () == n. So not having an implementation would break the
> concept, having an empty implementation would break the concept's post
> condition. A third option is to throw an exception (saying that it
> cannot be resized). I'm not sure if throwing an exception technically
> breaks the concept. If it does not, then we're fine. Otherwise, we
> should either consider changing the concept, or agree that
> fixed_vector does not implement the Vector concept (in which case
> naming it a "..._vector" is somewhat misleading).
I strongly prefer having the .resize() function on any constant sized vector to
aid in generic programming (exactly for this reason).
The solution to me seems that .resize() should exist, but it should assert
that you are trying to resize it to the exact same size as the fixed size
(at which point it becomes a null operation), or else it throws an exception.
This has come up in my code more than once.