This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: slices ; Stroustrup & libstdc++


On 19 Jun 2000 at 16:54 (+0200), Gerhard Wesp said:
| > mentioned that the valarray classes, "were not designed very well.
| > In fact, nobody tried to determine whether the final specification
| > worked."
| 
|   indeed i'm starting to get this impression.  (quite arrogant for a c++
| newbie like me, isn't it? ;-) the standard doesn't seem
| to define the very useful (IMO) computed assignment operators, like

// 26.3.2.6 computed assignment:
valarray<T>& operator*= (const T&);
valarray<T>& operator/= (const T&);
valarray<T>& operator%= (const T&);
valarray<T>& operator+= (const T&);
valarray<T>& operator-= (const T&);
valarray<T>& operator^= (const T&);
valarray<T>& operator&= (const T&);
valarray<T>& operator|= (const T&);
valarray<T>& operator<<=(const T&);
valarray<T>& operator>>=(const T&);

if you need to do these operations on slice_array<>, you'll
need to fill a valarray with the constT& that you want, then
apply the desired operator...

something like this (not tested)

std::valarray<int> a(10);
a = 10;
std::slice aslice(0,a.size()/2,2);
std::valarray<int> b(aslice.size());
b = 2;
a[aslice] += b;

hth.
  brent

-- 
Damon Brent Verner
Cracker JackŪ Certified Professional
brent@rcfile.org, brent@linux1.org

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]