language: C++ 4.7.2 (gcc-4.7.2)
date: 837 days 20 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
namespace N
{
    struct A
    {
        int x;
    }; 
}
 
bool operator<(const N::A& lhs, const N::A& rhs)
{
    return lhs.x<rhs.x;
}
 
namespace N2
{
     struct Q
    {
        int x;
    };
 
    //this code will compile, if we remove this operator  !!!!!!!!!!!!!!!!!
    bool operator<(const Q& lhs,const Q& rhs)
    {
        return lhs.x<rhs.x;
    }
    bool f(N::A a, N::A b)
    {
        return a<b;
    }
}
 
int main()
{
    N2::f(N::A(),N::A());
    return 0;
}
prog.cpp: In function ‘bool N2::f(N::A, N::A)’:
prog.cpp:28: error: no match for ‘operator<’ in ‘a < b’
prog.cpp:22: note: candidates are: bool N2::operator<(const N2::Q&, const N2::Q&)