E
ES Kim
comp.std.c++ would be a better place for this question.
Forgive me, but I can't post anything on moderated newsgroups
for some reason.
valarray doesn't have iterators of its own, which makes functions
in <algorithm> less useful. &v[0] works like an iterator, but even this
trick doesn't work for const valarray's.
void f(const valarray<double>& v)
{
copy(&v[0], &v[v.size()], ostream_iterator<int>(cout, " "));
}
This code doesn't compile (and it looks ugly, I'd say) since you can't
take the address of an r-value:
template<typename T>
T valarray<T>:perator[](size_t) const;
I'm curious the reason why the return type is T instead of const T& ?
I know valarray's are not meant for an ordinary container, but I think
there would be nothing to lose for taking advantage of const-correctness.
Forgive me, but I can't post anything on moderated newsgroups
for some reason.
valarray doesn't have iterators of its own, which makes functions
in <algorithm> less useful. &v[0] works like an iterator, but even this
trick doesn't work for const valarray's.
void f(const valarray<double>& v)
{
copy(&v[0], &v[v.size()], ostream_iterator<int>(cout, " "));
}
This code doesn't compile (and it looks ugly, I'd say) since you can't
take the address of an r-value:
template<typename T>
T valarray<T>:perator[](size_t) const;
I'm curious the reason why the return type is T instead of const T& ?
I know valarray's are not meant for an ordinary container, but I think
there would be nothing to lose for taking advantage of const-correctness.