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 

templatized templates - msvc .net 2003 bug found ??

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





PostPosted: Wed Jan 21, 2004 9:21 am    Post subject: templatized templates - msvc .net 2003 bug found ?? Reply with quote



I experienced a strange problem using msvc .net 2003 along with templatized
templates

here is an example :

namespace first
{
namespace second
{
template<typename T, class U, template
class ClassA
{
public:
typedef T value_type;
typedef Foo<value_type> Foo_type;
typedef typename Foo_type::reference reference;
};

template<typename T, class U, template template<typename BT, class BU, template class Bar>
class ClassB: private Bar<T,U,Foo>
{
public:
typedef T value_type;
typedef Foo<T> Foo_type;
typedef Bar<T,U,Foo> Bar_type;
typedef typename Bar_type::reference reference;
reference operator [] (int index);
};

template<typename T, class U, template template<typename BT, class BU, template class Bar>
inline typename ClassB<T,U,Foo,Bar>::reference
ClassB<T,U,Foo,Bar>::operator [] (int index)
{
return 0;
}
} // namespace second
} // namespace first

i get the following error message

Compiling...
BUG.cpp
d:BUGBUG.cpp(35) : error C2244:
'first::second::ClassB<T,U,Foo,Bar>::operator`[]'' : unable to match
function definition to an existing declaration
d:BUGBUG.cpp(2Cool : see declaration of
'first::second::ClassB<T,U,Foo,Bar>::operator`[]''
definition
'ClassB<T,U,Foo,Bar>::reference first::second::ClassB<T,U,Foo,Bar>::operator
[](int)'
existing declarations
'first::second::ClassB<T,U,Foo,Bar>::reference
first::second::ClassB<T,U,Foo,Bar>::operator [](int)'

when i change "typedef typename Bar_type::reference reference;" to "typedef
typename Foo_type::reference reference;" the error message disappear and the
code compiles
did i miss something or is it a msvc 7.1 bug ???

thx in advance,
best regards,
Gregory




[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Grégory Pakosz
Guest





PostPosted: Fri Jan 23, 2004 3:01 pm    Post subject: Re: templatized templates - msvc .net 2003 bug found ?? Reply with quote



so nobody tried to compile this little sample in order to find out what's
wrong with it ?

it really seems to be a msvc namespace resolution bug

thx for any help
Gregory



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Graeme Prentice
Guest





PostPosted: Sat Jan 24, 2004 9:38 pm    Post subject: Re: templatized templates - msvc .net 2003 bug found ?? Reply with quote



On 23 Jan 2004 10:01:22 -0500, Grégory Pakosz wrote:

Quote:
so nobody tried to compile this little sample in order to find out what's
wrong with it ?

it really seems to be a msvc namespace resolution bug


Your code compiles with Comeau and GCC. Even without the namespaces,
VC7.1 gets the same error so it's probably just the nested template
template parameter that causes the problem. For VC7.1 you can
workaround it as below - the code compiles but is untested. Did you
know you could compile code snippets online here
http://www.comeaucomputing.com/tryitout/

In case you don't know, the Comeau compiler is EDG based and the most
compliant compiler available (and cheap) and you can get GCC for Windows
at www.mingw.org


namespace first
{
namespace second
{
template<typename T, class U, template
class ClassA
{
public:
typedef T value_type;
typedef Foo<value_type> Foo_type;
typedef typename Foo_type::reference reference;
};

template <typename T>
struct helper1
{
typedef T T1;
};

template<typename T, class U, template template<typename BT, class BU, template class BF> class Bar>
class ClassB: public Bar<T,U,Foo>
{
public:
typedef T value_type;
typedef Foo<T> Foo_type;
typedef Bar<T,U,Foo> Bar_type;
//typedef typename Bar_type::reference reference;
typedef typename
helper1<typename Bar_type::reference>::T1 reference;
reference operator [] (int index);
};

template<typename T, class U, template template<typename BT, class BU, template class BF> class Bar>
inline typename ClassB<T,U,Foo,Bar>::reference
ClassB<T,U,Foo,Bar>::operator [] (int index)
{
return 0;
}
} // namespace second
} // namespace first


int main()
{
}


Graeme

[ 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.