Re: Problem with ostringstream and Daixtrose
Markus Werle <[email protected]> Wed, 11 Jan 2006 21:11:07 +0100
| Newsgroups | gmane.comp.lib.daixtrose.help |
|---|---|
| Message-ID | <[email protected]> |
Hi!
Yes, I dislike the way C++ name lookup is unable to be directed
to the right path here.
The reason for the error is that
using namespace Daixt::DefaultOps;
includes operator<< which is then chosen instead the correct one.
I should have investigated why this happens even for the case you
also say
using namespace std;
Seems like my operator is a better match - which i did not expect.
Unfortuantely Compilers reject
using std::operator<<;
and also I would appreciate C++ to have keyword "not"
not using Daixt::DefaultOps::operator<<
The only way you may get around this problem is by
using using declaratives (sic!) a la
using Daixt::DefaultOps::operator+;
using Daixt::DefaultOps::operator-;
using Daixt::DefaultOps::operator*;
using Daixt::DefaultOps::operator/;
using Daixt::DefaultOps::operator==;
using Daixt::DefaultOps::operator%=;
using Daixt::DefaultOps::Pow;
using Daixt::DefaultOps::RationalPow;
instead of using the whole namespace at once.
Things will get much better in the next evolution step
of my library, but this issue really bites.
Code snippet that compiles with intel-9 but still fails with
gcc-3.3.4 which has some trouble with the using stuff, so you
probably have to take a newer gcc - I am unsure here.
#include "daixtrose/Daixt.h"
#include "daixtrose/DefaultOps.h"
#include <iostream>
#include <sstream>
int main()
{
using namespace std;
using Daixt::DefaultOps::operator+;
//using namespace Daixt::DefaultOps;
std::ostringstream out;
//std::cout << "Test of sstream problem " << std::endl;
out << "Test of sstream problem " << std::endl;
std::cout << out.str();
return 0;
}
Btw.: I like to see someone else use my lib.
The key issues become clear in a way I could not
achieve myself. Thank you for beta-using!
best regards,
Markus
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click