Connecting Tech Pros Worldwide Help | Site Map

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

Stuart Redmann
Guest
 
Posts: n/a
#1: Dec 13 '07
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
Victor Bazarov
Guest
 
Posts: n/a
#2: Dec 13 '07

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


Stuart Redmann wrote:
Quote:
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?
Quote:
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).
Quote:
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


Stuart Redmann
Guest
 
Posts: n/a
#3: Dec 13 '07

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


Victor Bazarov wrote:
Quote:
Stuart Redmann wrote:
>
Quote:
>>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.
Quote:
Quote:
>>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]
Quote:
Quote:
>>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
anon
Guest
 
Posts: n/a
#4: Dec 13 '07

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


Stuart Redmann wrote:
Quote:
Victor Bazarov wrote:
>
Quote:
>Stuart Redmann wrote:
>>
Quote:
>>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)
Closed Thread