operator-() for valarray

Gabriel Dos Reis Gabriel.Dos-Reis@cmla.ens-cachan.fr
Sat Apr 1 00:00:00 GMT 2000


Takanori YOSHIKOSHI <tyoshiko@sci.osaka-cu.ac.jp> writes:

| Hi,
| 
| I can't compile the following program with gcc-2.95.2 and
| libstdc++-2.90.7.
| 
| // tmp.cc
| #include <valarray>
| 
| using namespace std;
| 
| int main()
| {
|   valarray<int> v(1, 3);
|   - v;
| }
| 
| $ g++ -I/usr/local/include/g++-v3 -L/usr/local/lib tmp.cc
| /usr/local/include/g++-v3/bits/valarray_meta.h: In instantiation of `_UnClos<negate,_ValArray,int>':
| /usr/local/include/g++-v3/bits/valarray_meta.h:643:   instantiated from `_Expr<_UnClos<negate,_ValArray,int>,int>'
| /usr/local/include/g++-v3/bits/std_valarray.h:553:   instantiated from `valarray<int>::operator -() const'
| tmp.cc:9:   instantiated from here
| /usr/local/include/g++-v3/bits/valarray_meta.h:339: no type named `result_type' in `class _UnBase<negate,valarray<int> >'
| 
| Is that a bug?

Definitely.  IT should read 'value_type'.  Here is a fix.

-- Gaby

2000-03-03 2000  Gabriel Dos Reis  <dosreis@cmla.ens-cachan.fr>

	* bits/valarray_meta.h: Fix typo.

Index: bits/valarray_meta.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/valarray_meta.h,v
retrieving revision 1.21
diff -p -r1.21 valarray_meta.h
*** valarray_meta.h	1999/11/19 01:07:33	1.21
--- valarray_meta.h	2000/03/03 15:15:23
*************** namespace std {
*** 336,342 ****
      struct _UnClos<_Oper, _ValArray, _Tp> : _UnBase<_Oper, valarray<_Tp> > {
          typedef valarray<_Tp> _Arg;
          typedef _UnBase<_Oper, valarray<_Tp> > _Base;
!         typedef typename _Base::result_type value_type;
  
          _UnClos (const _Arg& __e) : _Base(__e) {}
      };
--- 336,342 ----
      struct _UnClos<_Oper, _ValArray, _Tp> : _UnBase<_Oper, valarray<_Tp> > {
          typedef valarray<_Tp> _Arg;
          typedef _UnBase<_Oper, valarray<_Tp> > _Base;
!         typedef typename _Base::value_type value_type;
  
          _UnClos (const _Arg& __e) : _Base(__e) {}
      };



More information about the Libstdc++ mailing list