![]() |
Argument-Dependent Lookup
Dear experts,
As far as I understood the ADL concept things shoul work in the followin way. I have a global ostream operator defined as //ostreamtest.cpp #include<iostream> using namespace std; ostream& operator<<(ostream& out,const string& str) { out<<"in ostream"<<endl; out<<str.c_str()<<endl; return out; } int main() { } |
Re: Argument-Dependent Lookup
On May 15, 7:40 am, siddhu <siddharth....@gmail.com> wrote:
> As far as I understood the ADL concept things shoul work in the > followin way. > > ostream& operator<<(ostream& out,const string& str) > { > out<<"in ostream"<<endl; > out<<str.c_str()<<endl; > > return out; > } This function will never be found for an expression like: foo << bar; because of ADL ! The arguments are all in namespace std, so the compiler only searches namespace std. It doesn't find your function that's in the global namespace. Note that there is nothing you can do about this; trying to add your function to namespace std would cause undefined behaviour. |
| All times are GMT. The time now is 06:00 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.