The following fails under VC8 Beta2:
namespace A {
// forward decl.
template <typename Type, typename TypeX>
bool foo(const Type&, const TypeX&);
} // namespace A
namespace A {
namespace B {
template <typename Type>
struct S
{
template <typename Type, typename TypeX>
friend bool ::A::foo(const Type&, const TypeX&); // error C2888
protected:
template <typename TypeX>
static bool bar(const Type& a, const TypeX& b)
{
return a == b;
}
};
} // namespace B
template <typename Type, typename TypeX>
bool foo(const Type& a, const TypeX& b)
{
return B::S<Type>::bar (a, b);
}
} // namespace A
int main()
{
}
The error message is:
..\Test.cpp(114 ) : error C2888: 'bool A::foo(const Type &,const TypeX
&)' : symbol cannot be defined within namespace 'B'
..\Test.cpp(122 ) : see reference to class template instantiation
'A::B::S<Type>' being compiled
Can someone explain why?
Thanks,
- NK 5 4455
"narechk" <na*****@gmail. com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com The following fails under VC8 Beta2:
namespace A {
// forward decl. template <typename Type, typename TypeX> bool foo(const Type&, const TypeX&);
} // namespace A
namespace A { namespace B {
template <typename Type> struct S { template <typename Type, typename TypeX> friend bool ::A::foo(const Type&, const TypeX&); // error C2888
protected: template <typename TypeX> static bool bar(const Type& a, const TypeX& b) { return a == b; } };
} // namespace B
template <typename Type, typename TypeX> bool foo(const Type& a, const TypeX& b) { return B::S<Type>::bar (a, b); }
} // namespace A
int main() { } The error message is:
.\Test.cpp(114) : error C2888: 'bool A::foo(const Type &,const TypeX &)' : symbol cannot be defined within namespace 'B' .\Test.cpp(122) : see reference to class template instantiation 'A::B::S<Type>' being compiled
Can someone explain why?
There appears to be a bug: http://lab.msdn.microsoft.com/produc...2-d67ccd795fc7
--
John Carson
* narechk:
Compiles fine with gcc 3.4.2.
Also compiles fine with Comeau Online when the struct S template parameter
is renamed to e.g. "LType" (and correspondingly for S::bar).
Otherwise Comeau detects a "template parameter "Type" may not be redeclared
in this scope", but the fix for Comeau doesn't help with Visual C++ 7.1 (I
don't have the 8.0 beta 2).
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Right. This is not good. Does anyone know if there is a workaround?
Thanks,
- NK
* narechk: Right. This is not good. Does anyone know if there is a workaround?
E.g. place foo in namespace B and just a forwarding foo in namespace A.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Everyone thanks for your help. This is a real bloody showstopper. Will
have to redesign.
- NK This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: James Thurley |
last post by:
I'm trying to dynamically compile assemblies and cache them to disk,
which seems to work fine. When the data I'm compiling from changes, I
want to re-generate the assembly and use the new version.
After I re-generate the assembly, I get the type I want from it and
then invoke a static method.
I have found the following behaviour:
1....
|
by: Fernando Cuenca |
last post by:
Hi,
I'm trying to explicitly instantiate a template function using the
following syntax:
obj.template_func<type>(params);
It compiles OK when used from a regular function, but it doesn't
compile when used in a template function. Is there any particular
reason for this, or is this a compiler bug? I'm using GCC 3.2.3 on
|
by: Rhino |
last post by:
I am having an odd problem: the sqlj command on my system doesn't work.
I am running DB2 (LUW) V8 (FP8) on WinXP.
I haven't done an sqlj program since Version 6 of DB2 (LUW) so I checked the
manuals for the proper techniques to prepare an sqlj program. When I went to
try the sqlj command, I got this:
Exception in thread "main"...
|
by: Karl Irvin |
last post by:
When I click Debug>Compile, my modules seem to comple OK but the Compile
menu choice doesn't gray out (to indicate compiling is not needed).
The IsCompiles returns false, no matter how many times I click Compile.
Access 2000
|
by: Christopher Benson-Manica |
last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.)
strchr() is to strrchr() as strstr() is to strrstr(), but strrstr()
isn't part of the standard. Why not?
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
| |
by: rvan |
last post by:
Hi,
I am trying to port one of my older MFC APP created in VC
6.0 to VC 7.0. Right away after starting the compile
process, I get following errors and compilation stops.
"d:\Microsoft .NET 2002\Vc7\atlmfc\include\atltime.h
error C2065: 'm_hWnd' : undeclared
identifier", "d:\Microsoft .NET 2002\Vc7
\atlmfc\include\atltime.h error C2501:...
|
by: Eric Lilja |
last post by:
Is this an invalid program? Doesn't compile on my system:
#include <cstdio>
class Why
{
enum TArch {LITTLE_ENDIAN, BIG_ENDIAN, NON_IEEE};
TArch Architecture;
};
int
|
by: Sourcerer |
last post by:
I wrote this very simple code in .NET VC++. I compiled it on my system, and
tried to run it on my friend's computer (he doesn't have the compiler). We both
have Windows XP Professional. I have .NET framework 2.0, and he had 1.0 and it
didn't work; then he installed 2.0 and it still didn't work; so he tried with
2.1 and it didn't work, then 3.0...
|
by: hn.ft.pris |
last post by:
Hi:
I have the following simple program:
#include<iostream>
using namespace std;
int main(int argc, char* argv){
const double L = 1.234;
const int T = static_cast<const int>(L);
int arr;
|
by: mwelsh1118 |
last post by:
Why doesn't C# allow incremental compilation like Java?
Specifically, in Java I can compile single .java files in isolation.
The resulting individual .class files can be grouped into .jar files.
In C#, there appears to be no analog. I have to compile all my .cs
files into a single .dll.
This has serious drawbacks in terms of...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |