C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

trouble with finding the correct operator

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Torsten Robitzki
Guest





PostPosted: Sun Jan 25, 2004 10:46 am    Post subject: trouble with finding the correct operator Reply with quote



Hi,
recently I've bought the latest MS c++ compiler to see if my current fun
project would compile with an other compiler then g++. I got error
messages in the serialization support code for template functions that
should write other templates like std::pair<> of boost::shared_ptr<>.
I'm not sure if koenig lookup should bring up the operators name I'm
like to see into the scope of this functions. Here's a simple reproducer
and the error message:

#include <utility>

namespace ns2
{
class cl
{
public:
template <class A, class B>
cl& operator<<(const std::pair };
}
namespace ns1
{
class foo
{
};

ns2::cl& operator<<(ns2::cl&, const foo&);
}

namespace ns2
{

template cl& cl::operator<<(const std::pair {
return *this << t.first << t.second; // line 27
}
}

void f()
{
ns1::foo f;
ns2::cl c;
c<<(std::pair }

The error message (translated from german) :
$ cl /c /I"C:ProgrammeMicrosoft Visual Studio .NET 2003Vc7include"
test.cpp
Microsoft (R) 32-Bit C/C++-Standardcompiler Version 13.10.3077 f r 80x8
6
Copyright (C) Microsoft Corporation 1984-2002. Alle Rechte vorbehalten.

test.cpp
test.cpp(27) : error C2784: 'ns2::cl &ns2::cl::operator <<(const
std::pair
von 'const ns1::foo' can not be deduced
test.cpp(9): see declaration of 'ns2::cl::operator`<<''
test.cpp(35): instanciated from here 'ns2::cl
&ns2::cl::operator << with
[
Ty1=ns1::foo,
Ty2=ns1::foo
]
test.cpp(27) : error C2676: binary operator '<<': 'ns2::cl' does not
define this operator or a conversion in a manner allowed for this
operator type

I guess this is a bug with the MS compiler, but I'm not sure. The only
workaround I've found so far is to inject the n1 namespace into the
operator<<(std::pair<>) by a 'using namespace n1'.

Can someone confirm that this is a bug? Does someone have a better
workaround for my problem?

thanks in advanced
Torsten


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.