* Chris Forone:
First, disclaimer: I'm not familiar with valarray.
But much of the reason that I'm not familiar with it is that valarray is
essentially an unfinished class.
One that isn't used in practice, the Most Useless part of the standard
library.
Who knows what the author had in mind?
That said, it looks like much of the purpose was to provide a class
where operations could be optimized by certain processors, performing
element operations in parallel, and that /could/ be easier for the
processor to do if direct modifictions of single elements was
prohibited. However, valarray itself allows modification of single
elements. So, it seems like something half-baked, with the design not
fully flushed out, but beware of the disclaimer above!
Yes, don't do it.
To avoid gross inefficiency you'd have to delve into your particular
implementation, i.e. non-portable code.
Otherwise you could always copy that subset to a new valarray, change a
single element, and copy the whole shebang back...
Cheers, & hth.,
- Alf