S
skywal_l
Hi,
I got a problem with this code:
// Starts here
#include <iostream>
#include <vector>
class A {};
std::vector<A> operator>>(A &a, const std::string &s)
{
std::vector<A> v;
v.push_back(a);
return v;
}
std::vector<A> operator>>(const std::string &s, A a)
{
std::vector<A> v;
v.push_back(a);
return v;
}
std::vector<A> &operator>>(A &a, std::vector<A> &v)
{
v.push_back(a);
return v;
}
std::vector<A> &operator>>(std::vector<A> &v, A a)
{
v.push_back(a);
return v;
}
std::vector<A> &operator>>(std::vector<A> &v, const std::string &s)
{
return v;
}
std::vector<A> &operator>>(const std::string &s, std::vector<A> &v)
{
return v;
}
int main(int, char **)
{
A a;
"titi" >> a >> "toto";
return 0;
}
// Ends here
This code would not compile with g++ 4.0.6 which fails this way:
:~/gcc$ g++ test.cpp
test.cpp: In function #int main(int, char**)#:
test.cpp:48: error: no match for `operator>>' in `operator>>(const
std::string&, A)((a, A())) >> "toto"'
test.cpp:6: note: candidates are: std::vector<A, std::allocator<A> >
operator>>(A&, const std::string&)
test.cpp:14: note: std::vector<A, std::allocator<A> >
operator>>(const std::string&, A)
test.cpp:22: note: std::vector<A, std::allocator<A> >&
operator>>(A&, std::vector<A, std::allocator<A> >&)
test.cpp:28: note: std::vector<A, std::allocator<A> >&
operator>>(std::vector<A, std::allocator<A> >&, A)
test.cpp:34: note: std::vector<A, std::allocator<A> >&
operator>>(std::vector<A, std::allocator<A> >&, const std::string&)
test.cpp:39: note: std::vector<A, std::allocator<A> >&
operator>>(const std::string&, std::vector<A, std::allocator<A> >&)
Any idea??
Thanks.
I got a problem with this code:
// Starts here
#include <iostream>
#include <vector>
class A {};
std::vector<A> operator>>(A &a, const std::string &s)
{
std::vector<A> v;
v.push_back(a);
return v;
}
std::vector<A> operator>>(const std::string &s, A a)
{
std::vector<A> v;
v.push_back(a);
return v;
}
std::vector<A> &operator>>(A &a, std::vector<A> &v)
{
v.push_back(a);
return v;
}
std::vector<A> &operator>>(std::vector<A> &v, A a)
{
v.push_back(a);
return v;
}
std::vector<A> &operator>>(std::vector<A> &v, const std::string &s)
{
return v;
}
std::vector<A> &operator>>(const std::string &s, std::vector<A> &v)
{
return v;
}
int main(int, char **)
{
A a;
"titi" >> a >> "toto";
return 0;
}
// Ends here
This code would not compile with g++ 4.0.6 which fails this way:
:~/gcc$ g++ test.cpp
test.cpp: In function #int main(int, char**)#:
test.cpp:48: error: no match for `operator>>' in `operator>>(const
std::string&, A)((a, A())) >> "toto"'
test.cpp:6: note: candidates are: std::vector<A, std::allocator<A> >
operator>>(A&, const std::string&)
test.cpp:14: note: std::vector<A, std::allocator<A> >
operator>>(const std::string&, A)
test.cpp:22: note: std::vector<A, std::allocator<A> >&
operator>>(A&, std::vector<A, std::allocator<A> >&)
test.cpp:28: note: std::vector<A, std::allocator<A> >&
operator>>(std::vector<A, std::allocator<A> >&, A)
test.cpp:34: note: std::vector<A, std::allocator<A> >&
operator>>(std::vector<A, std::allocator<A> >&, const std::string&)
test.cpp:39: note: std::vector<A, std::allocator<A> >&
operator>>(const std::string&, std::vector<A, std::allocator<A> >&)
Any idea??
Thanks.