S
siddhu
Dear experts,
As far as I understood the ADL concept things should work in the
following 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()
{
string s("abcd");
cout<<s<<endl;
}
The output of above program is
in ostream
abcd
That means It is calling global ostream operator. But I expected from
this program to call ostream operator defined in std namespace.
Suggestions would be of great help.
Regards,
Siddharth
As far as I understood the ADL concept things should work in the
following 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()
{
string s("abcd");
cout<<s<<endl;
}
The output of above program is
in ostream
abcd
That means It is calling global ostream operator. But I expected from
this program to call ostream operator defined in std namespace.
Suggestions would be of great help.
Regards,
Siddharth