Re: const and valarray reference
From: Victor Bazarov (v.Abazarov_at_attAbi.com)
Date: 10/23/03
- Next message: Grzegorz Sakrejda: "Re: traits help"
- Previous message: Mike Wahler: "Re: my own streams"
- In reply to: Jim West: "const and valarray reference"
- Next in thread: Jim West: "Re: const and valarray reference"
- Reply: Jim West: "Re: const and valarray reference"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 23 Oct 2003 21:55:32 GMT
"Jim West" <eggplantparts@yahoo.com> wrote...
>
> The following compiles with g++ 3.3.2, but fails with Intel icc 7.1 with
> the error:
>
> asdf.cc(6): error: expression must be an lvalue or a function designator
> f1(&arr[0]);
>
> Is this undefined behavior, or have I found a problem with one compiler?
>
> Code sample is:
>
> void f1(const double *);
>
> void f2(const std::valarray<double> &arr) {
> f1(&arr[0]);
> }
Constant std::valarray's operator[] returns an rvalue. You
cannot take an address of it. What are you trying to accomplish?
Perhaps changing f1 to accept a double const & would help:
void f1(double const&);
void f2(std::valarray<double> const& arr) {
f1(arr[0]);
}
?
Victor
- Next message: Grzegorz Sakrejda: "Re: traits help"
- Previous message: Mike Wahler: "Re: my own streams"
- In reply to: Jim West: "const and valarray reference"
- Next in thread: Jim West: "Re: const and valarray reference"
- Reply: Jim West: "Re: const and valarray reference"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|