Topic: proposal for resolution of "valarray operator[] const returning


Author: Pete Becker <petebecker@acm.org>
Date: Thu, 14 Feb 2002 18:13:27 GMT
Raw View
Markus Werle wrote:
>
> I for myself can think of a lot of cases in which I wished
> to have all the functionality of valarray, but a return type of
> const reference, (e.g. valarray<map<size_t, double> > for
> compressed matrices)

valarray was designed to be instantiated with numeric types, not
composite types.

What should the function cos do when passed an argument of type
valarray<map<size_t, double> >?

--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Pete Becker <petebecker@acm.org>
Date: Thu, 14 Feb 2002 23:28:21 GMT
Raw View
Gabriel Dos Reis wrote:
>
> Pete Becker <petebecker@acm.org> writes:
>
> | Markus Werle wrote:
> | >
> | > I for myself can think of a lot of cases in which I wished
> | > to have all the functionality of valarray, but a return type of
> | > const reference, (e.g. valarray<map<size_t, double> > for
> | > compressed matrices)
> |
> | valarray was designed to be instantiated with numeric types, not
> | composite types.
>
> That doesn't invalide the real problems posed by making that operator
> returning a const.
>

Huh? How does returning a const reference make it reasonable to compute
the cosine of a valarray<map<size_t,double> >? Or does your comment have
nothing to do with what I said?

--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Pete Becker <petebecker@acm.org>
Date: Fri, 15 Feb 2002 19:09:18 CST
Raw View
Gabriel Dos Reis wrote:
>
> Pete Becker <petebecker@acm.org> writes:
>
> | Gabriel Dos Reis wrote:
> | >
> | > Pete Becker <petebecker@acm.org> writes:
> | >
> | > | Markus Werle wrote:
> | > | >
> | > | > I for myself can think of a lot of cases in which I wished
> | > | > to have all the functionality of valarray, but a return type of
> | > | > const reference, (e.g. valarray<map<size_t, double> > for
> | > | > compressed matrices)
> | > |
> | > | valarray was designed to be instantiated with numeric types, not
> | > | composite types.
> | >
> | > That doesn't invalide the real problems posed by making that operator
> | > returning a const.
> | >
> |
> | Huh? How does returning a const reference make it reasonable to compute
> | the cosine of a valarray<map<size_t,double> >?
>
> I didn't say it makes it reasonable to compute the cosine of a
> valarray<map<size_t, double> >.  I said, your remark doesn't
> invalidate the problem caused by that operator returning a value
> instead of const reference.
>

I had no intention of addressing that possible problem, so I must have
written my response correctly.

--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]