help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: std::distance


From: Artus
Subject: Re: std::distance
Date: Fri, 24 Mar 2006 11:10:35 +0100
User-agent: Thunderbird 1.5 (Windows/20051201)

Hi, I have a problem compiling the following code with g++.
It works fine with Sun CC5.3

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&)'

Thanks for any help.
Artus

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]