473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Using declaration inside first template parameter as default valuefor second template parameter.

Hello newsgroup,

please don't flame me: I use the very old and very non-conformant MS VC6.0
compiler. Though I'd like to upgrade to a better compiler, I'm afraid that some
of my code will break. One of the "features" of MS VC6.0 is the following:

template<class A, class B = A::Type>
class C
{
};

class D
{
public:
typedef D Type;
};

int main ()
{
D d;
}

This compiles fine under VC, and does what I expect it to do (in my real
application, not this down-cut sample). I tried to compile it with Comeau
online, and surprise, surprise, it gives an error:

"ComeauTest.c", line 1: error: nontype "A::Type" is not a type name
template<class A, class B = A::Type>
^

What do I have to do to make the code work under Comeau?

Thanks,
Stuart
Dec 13 '07 #1
3 1505
Stuart Redmann wrote:
please don't flame me: I use the very old and very non-conformant MS
VC6.0 compiler. Though I'd like to upgrade to a better compiler, I'm
afraid that some of my code will break.
Wow... What do you say to that, eh?

Do you leave your house at all or are you afraid you will be hit with
a bus? How do you code at all? You must be afraid that whatever you
write has a bug or two in it... Or does the code you write work the
first time and always?
One of the "features" of MS
VC6.0 is the following:
template<class A, class B = A::Type>
Change this to

template<class A, class B = typename A::Type>

But I am not sure your outdated and non-standard VC++ is going to
accept that (and I don't have any way to check).
class C
{
};

class D
{
public:
typedef D Type;
};

int main ()
{
D d;
}

This compiles fine under VC, and does what I expect it to do (in my
real application, not this down-cut sample). I tried to compile it
with Comeau online, and surprise, surprise, it gives an error:

"ComeauTest.c", line 1: error: nontype "A::Type" is not a type name
template<class A, class B = A::Type>
^

What do I have to do to make the code work under Comeau?
Write standard C++.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 13 '07 #2
Victor Bazarov wrote:
Stuart Redmann wrote:
>>please don't flame me: I use the very old and very non-conformant MS
VC6.0 compiler. Though I'd like to upgrade to a better compiler, I'm
afraid that some of my code will break.

Wow... What do you say to that, eh?

Do you leave your house at all or are you afraid you will be hit with
a bus? How do you code at all? You must be afraid that whatever you
write has a bug or two in it... Or does the code you write work the
first time and always?
Don't blame me, the decision to use MS VC6.0 was not made by me but my employer.
Have you tried at some time to ask your boss permission for some hundred
man-hours working on your software without A) adding some features or B) fixing
any bugs? Maybe I expressed it badly: I'm afraid that I'll have to spend too
much time to make my otherwise working code more standard-conformant.
>>One of the "features" of MS
VC6.0 is the following:
template<class A, class B = A::Type>


Change this to

template<class A, class B = typename A::Type>

But I am not sure your outdated and non-standard VC++ is going to
accept that (and I don't have any way to check).
Surprisingly, it does.

[snip]
>>What do I have to do to make the code work under Comeau?


Write standard C++.
That's hardly a guarantee that the code will actually work. AFAIK, there is no
compiler that is 100 percent standard-conformant.

Many thanks,
Stuart
Dec 13 '07 #3
Stuart Redmann wrote:
Victor Bazarov wrote:
>Stuart Redmann wrote:
>>please don't flame me: I use the very old and very non-conformant MS
VC6.0 compiler. Though I'd like to upgrade to a better compiler, I'm
afraid that some of my code will break.

Wow... What do you say to that, eh?

Do you leave your house at all or are you afraid you will be hit with
a bus? How do you code at all? You must be afraid that whatever you
write has a bug or two in it... Or does the code you write work the
first time and always?

Don't blame me, the decision to use MS VC6.0 was not made by me but my
employer. Have you tried at some time to ask your boss permission for
some hundred man-hours working on your software without A) adding some
features or B) fixing any bugs? Maybe I expressed it badly: I'm afraid
that I'll have to spend too much time to make my otherwise working code
more standard-conformant.
But, isn't your code already broken if you are using "very old and very
non-conformant" compiler? By updating the compiler, you will:
A) add features easier
B) fix existing bugs in your code
Therefore, the time you invest will pay off (not only for you, but also
for people working on the project)
Dec 13 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and...
8
by: Douglas | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** Hello, The following code does not compile if line 3 is uncommented "using namespace std". I do not understand it. Could...
13
by: Walt Karas | last post by:
The following gives an error in the declaration of the member function x() of the class template Tpl, compiliing with a recent version of GCC under Solaris: class A { }; class B { }; ...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
0
by: Horia Tudosie | last post by:
Using Visual Studio 2003 This is to report a series of bugs regarding the FlagsAttribute and (independently) the usage of interfaces in Web applications. Let’s declare xColors type like: ...
18
by: sunny | last post by:
Hi Why does C allows declaration of variable inside switch block. ex: foll prg does not gives "undeclared "b" error msg. but also does not initialize b to 20 int a=1; switch(a) { int b=20;...
3
by: Adam Nielsen | last post by:
Hi everyone, Yet another syntax problem that's baffling me with templates. I want to instantiate a template with a single parameter as per normal, however the parameter is actually a template...
2
by: Heltende | last post by:
I'm trying to develop a stylesheet that takes a parameter that is used to filter the results. It works great *except* for the fact that I want one of my options to be a "See All", removing any...
9
by: shakilalig | last post by:
Hi All, I am writing an XSL to transform the XML to XML.Only change i need in xml is to add the value for the price element under book tag for which publisher location is "World". The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
agi2029
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,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.