Artus <[EMAIL PROTECTED]> writes:

> double tab[] = {0.6, 1.0, 3.0, 10.0, 20.0, 50., 1000.};
> std::vector<double> const myvec(tab, tab+sizeof(tab)/sizeof(double));
> /* ... */
> for (std::vector<double>::const_iterator it = myvec.begin();
> it!=myvec.end(); ++it) {
>      std::vector<double>::difference_type i = 0;
>      std::distance(myvec.begin(), it, i);
>      /* .. */
> }
>
> The compilation error message reads :
>
> error: no matching function for call to
> `distance(__gnu_cxx::__normal_iterator<const double*,
> std::vector<double, std::allocator<double> > >,
> __gnu_cxx::__normal_iterator<const double*, std::vector<double,
> std::allocator<double> > >&, ptrdiff_t&)'

std::distance() only takes two parameters. Does

std::vector<double>::difference_type dist(std::distance(myvec.begin(), it));

work?


> P.S. : I cannot use the version of std::distance with a return
> value, as it does not work under Sun CC5.3

I see. Then you are out of luck, because there is no other version in
Standard C++.
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to