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: valarray problem with gcc-2.95.1


Serge Barral <sbarral@ippt.gov.pl> writes:

| Gabriel Dos Reis wrote:
| [...]
| > First some C++ rules recollection: when a member function is
| > overloaded using 'const', the const version is selected only when the
| > expression used to invoke it is 'const'.  Thus 'c[range]' in
| > 
| >         c[range] + c[range]
| > 
| > is of type slice_array<double> and not valarray<double>.
| 
| Hoops! Sorry for this...
| 
| But my second question remains, however:
| even if 'c' is 'const', I get a compile error for an expression like:
| 
|          exp(c[range])
| 
| In the draft of ANSI C++ at http://www.cygnus.com/misc/wp, the
| mathematical functions like cos, abs, exp... are overloaded by something
| like:
| 
| template<class T> valarray<T> exp(const valarray<T>&);


Well actually, that is my fault: I was attempting to build a
meta-expression from another meta-expression instead of taking the
contained closure.  The appended patch should correct that bug.
Please let me know if the bug persists (it should not :-)

| Did I (once more ;-) miss something, or is this not yet implemented in
| libstdc++?

No, you didn't miss anything :-)

-- Gaby

1999-11-05  Gabriel Dos Reis  <dosreis@cmla.ens-cachan.fr>

	* bits/valarray_meta.h (_DEFINE_EXPR_UNARY_FUNCTION): When
	building meta-expressions don't forget to take the contained
	closures. 

Index: bits/valarray_meta.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/valarray_meta.h,v
retrieving revision 1.19
diff -r1.19 valarray_meta.h
928c928
<     return _Expr<_Closure,_Tp> (_Closure (__e, (_Tp(*)(_Tp))(&_Name))); \
---
>     return _Expr<_Closure,_Tp>(_Closure(__e(), (_Tp(*)(_Tp))(&_Name))); \

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