slices ; Stroustrup & libstdc++
Gabriel Dos Reis
Gabriel.Dos-Reis@cmla.ens-cachan.fr
Sun Jun 18 14:06:00 GMT 2000
Gerhard Wesp <gwesp@cosy.sbg.ac.at> writes:
| hi all,
|
| i just tried a slice_array example from stroustrup, 3rd ed., p. 671
| which fails with the following error:
|
| grisu ~/c++% cat slice.cc
| #include <valarray>
|
| void f(std::valarray<double>& d)
| {
| std::slice_array<double>& v_even = d[std::slice(0,d.size()/2,2)];
^
This is ill-formed: you can't bind a non-const reference to a
temporary. The two versions of valarray<T>::operator[](slice) return
by *value*.
-- Gaby
More information about the Libstdc++
mailing list