This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/15910] can't compile self defined void distance(std::vector<T>, std::vector<T>)


------- Additional Comments From adah at netstd dot com  2005-08-08 02:26 -------
Sorry, but some of you here have not read carefully enough and acted in a 
haste.  Please test with the following code piece and make a decision AFTER 
that:

#include <iostream>
#include <vector>

int distance(std::vector<int> v1, std::vector<int> v2)
{
    std::cout << "I am chosen!" << std::endl;
    return v1.size() - v2.size();
}

// Begins the hack
namespace std {

template<>
struct iterator_traits<vector<int> >
{
    typedef int iterator_category;
    typedef int value_type;
    typedef int difference_type;
    typedef int distance_type;
    typedef int pointer;
    typedef int reference;
};

}
// End the hack

int main()
{
    std::vector<int> v1(3), v2(1);
    int d = distance(v1, v2);
    return 0;
}

The point is: adding the seemingly unrelated code will make the user distance 
be chosen.

Best regards,

Yongwei


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15910


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]