470,641 Members | 1,606 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,641 developers. It's quick & easy.

templates and managed code

Is there any plan to support templates with managed code in the (near)
future? For instance, VS.NET 2005... : )
Nov 17 '05 #1
11 1493
Peter Oliphant wrote:
Is there any plan to support templates with managed code in the (near)
future? For instance, VS.NET 2005... : )


Templates have always (i.e. from the VS 2002 / 7.0 version) been
supported in managed code.

Templates on CLR types are supported starting with the VS 2005 / 8.0
versions.

Ronald Laeremans
Visual C++ team
Nov 17 '05 #2
Hey Peter

See http://www.codeproject.com/managedcpp/whycppcli.asp

See the section titled "Managed templates"

--
Regards,
Nish [VC++ MVP]
"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:OU**************@TK2MSFTNGP10.phx.gbl...
Is there any plan to support templates with managed code in the (near)
future? For instance, VS.NET 2005... : )

Nov 17 '05 #3
template< int x >
class X {} ; // just fine

template< int y >
__gc classY{} ; //error C3151 '__gc' can't be applied to a template

What do you mean by 'templates have always been supported' if the simple
code above generates an error specifically saying you can't use '__gc' with
a template? [ I'm using the 2003 pro version of VC++.NET]

I guess I don't know what a CLR type is... : )
"Ronald Laeremans [MSFT]" <ro*****@online.microsoft.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Peter Oliphant wrote:
Is there any plan to support templates with managed code in the (near)
future? For instance, VS.NET 2005... : )


Templates have always (i.e. from the VS 2002 / 7.0 version) been supported
in managed code.

Templates on CLR types are supported starting with the VS 2005 / 8.0
versions.

Ronald Laeremans
Visual C++ team

Nov 17 '05 #4
Peter Oliphant wrote:
template< int x >
class X {} ; // just fine

template< int y >
__gc classY{} ; //error C3151 '__gc' can't be applied to a template

What do you mean by 'templates have always been supported' if the
simple code above generates an error specifically saying you can't
use '__gc' with a template? [ I'm using the 2003 pro version of
VC++.NET]
I guess I don't know what a CLR type is... : )


You can' declare managed template types, but you can use templates inside
Managed C++ code (in non-gc types).

Starting with VC2005 and CLI, you can use generics on managed types
(although not really as powerful as templates, generics are a first step in
the right direction).

Arnaud
MVP - VC
Nov 17 '05 #5
Managed templates are supported starting VC++ 2005 (and I believe it's only
for the new syntax).

VC++ 2003 did not support managed templates. But, what Ronald meant is that
your native templates would compile with /clr turned on - doesn't mean you
can have __gc template classes.

--
Regards,
Nish [VC++ MVP]
"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:u7**************@TK2MSFTNGP12.phx.gbl...
template< int x >
class X {} ; // just fine

template< int y >
__gc classY{} ; //error C3151 '__gc' can't be applied to a template

What do you mean by 'templates have always been supported' if the simple
code above generates an error specifically saying you can't use '__gc'
with a template? [ I'm using the 2003 pro version of VC++.NET]

I guess I don't know what a CLR type is... : )
"Ronald Laeremans [MSFT]" <ro*****@online.microsoft.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Peter Oliphant wrote:
Is there any plan to support templates with managed code in the (near)
future? For instance, VS.NET 2005... : )


Templates have always (i.e. from the VS 2002 / 7.0 version) been
supported in managed code.

Templates on CLR types are supported starting with the VS 2005 / 8.0
versions.

Ronald Laeremans
Visual C++ team


Nov 17 '05 #6
Cool that it will be supported in 2005 (which will be released when? It's
close to needing a name change to 2006...lol)...

Will multiple-inheritance for managed (__gc) classes also be supported
perchance? In this case I would assume, if it's allowed at all, that when
creating a new managed multiple-inheritance class it would allow the use of
only *managed* base classes as parents...

Or is there a way to do managed multiple-inheritance now?

"Nishant Sivakumar" <ni**@nospam.asianetindia.com> wrote in message
news:u1****************@TK2MSFTNGP12.phx.gbl...
Managed templates are supported starting VC++ 2005 (and I believe it's
only for the new syntax).

VC++ 2003 did not support managed templates. But, what Ronald meant is
that your native templates would compile with /clr turned on - doesn't
mean you can have __gc template classes.

--
Regards,
Nish [VC++ MVP]
"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:u7**************@TK2MSFTNGP12.phx.gbl...
template< int x >
class X {} ; // just fine

template< int y >
__gc classY{} ; //error C3151 '__gc' can't be applied to a template

What do you mean by 'templates have always been supported' if the simple
code above generates an error specifically saying you can't use '__gc'
with a template? [ I'm using the 2003 pro version of VC++.NET]

I guess I don't know what a CLR type is... : )
"Ronald Laeremans [MSFT]" <ro*****@online.microsoft.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Peter Oliphant wrote:
Is there any plan to support templates with managed code in the (near)
future? For instance, VS.NET 2005... : )

Templates have always (i.e. from the VS 2002 / 7.0 version) been
supported in managed code.

Templates on CLR types are supported starting with the VS 2005 / 8.0
versions.

Ronald Laeremans
Visual C++ team



Nov 17 '05 #7
On Tue, 11 Oct 2005 15:31:43 -0700, "Peter Oliphant"
<po*******@RoundTripInc.com> wrote:
Cool that it will be supported in 2005 (which will be released when? It's
close to needing a name change to 2006...lol)...
See:

http://lab.msdn.microsoft.com/vs2005/

The "Launch Tour" begins Nov 7, so I guess it'll all be available then.
Will multiple-inheritance for managed (__gc) classes also be supported
perchance? In this case I would assume, if it's allowed at all, that when
creating a new managed multiple-inheritance class it would allow the use of
only *managed* base classes as parents...

Or is there a way to do managed multiple-inheritance now?


The CLR allows a class to implement multiple interfaces, but it doesn't
support multiple inheritance of classes. The new C++/CLI language follows
the CLR WRT managed types.

--
Doug Harrison
Visual C++ MVP
Nov 17 '05 #8

Peter Oliphant wrote:
Cool that it will be supported in 2005
Beware that managed generics are *NOT* templates, although the
(unfortunately IMHO) share most of their syntax. Mainly, generics do
not support specialization (partial or total), nor dependent types
definition/inference. On the other side, generics use a mechanism to
restrict what instanciations are authorized for a given "template".


Will multiple-inheritance for managed (__gc) classes also be supported
perchance? Managed C++ allows only interface multiple-inheritance and class single
inheritance. Otherwise, it would be incompatible with other .NET
langages and the .NET CLR.

Or is there a way to do managed multiple-inheritance now?

You can multiple-inherits from interfaces. Implementation
multiple-inheritance, although sometimes invaluable, should bu used
only on rare occasions anyway (most of the time, using MI means that
you are using inheritance for something else than the Liskov
Substitution principle).

Arnaud
MVP - VC

Nov 17 '05 #9
>Beware that managed generics are *NOT* templates, although the
(unfortunately IMHO) share most of their syntax. Mainly, generics do
not support specialization (partial or total), nor dependent types
definition/inference. On the other side, generics use a mechanism to
restrict what instanciations are authorized for a given "template".
I wasn't talking about generics - I was talking about managed templates
which support specialization, derivation from the template parameter type
etc.

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
<ad******@club-internet.fr> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Peter Oliphant wrote:
Cool that it will be supported in 2005


Beware that managed generics are *NOT* templates, although the
(unfortunately IMHO) share most of their syntax. Mainly, generics do
not support specialization (partial or total), nor dependent types
definition/inference. On the other side, generics use a mechanism to
restrict what instanciations are authorized for a given "template".


Will multiple-inheritance for managed (__gc) classes also be supported
perchance?

Managed C++ allows only interface multiple-inheritance and class single
inheritance. Otherwise, it would be incompatible with other .NET
langages and the .NET CLR.

Or is there a way to do managed multiple-inheritance now?

You can multiple-inherits from interfaces. Implementation
multiple-inheritance, although sometimes invaluable, should bu used
only on rare occasions anyway (most of the time, using MI means that
you are using inheritance for something else than the Liskov
Substitution principle).

Arnaud
MVP - VC

Nov 17 '05 #10
Nishant Sivakumar wrote:
Beware that managed generics are *NOT* templates, although the
(unfortunately IMHO) share most of their syntax. Mainly, generics do
not support specialization (partial or total), nor dependent types
definition/inference. On the other side, generics use a mechanism to
restrict what instanciations are authorized for a given "template".


I wasn't talking about generics - I was talking about managed
templates which support specialization, derivation from the template
parameter type etc.


I know, but I was not sure that Peter Oliphant was aware of the difference.

Arnaud
MVP - VC
Nov 17 '05 #11
Hi Arnad,
I know, but I was not sure that Peter Oliphant was aware of the
difference.
I wasn't till now, so thanx for info! In fact, thanks to all who have
participated in this thread... : )

[==P==]

"Arnaud Debaene" <ad******@club-internet.fr> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl... Nishant Sivakumar wrote:
Beware that managed generics are *NOT* templates, although the
(unfortunately IMHO) share most of their syntax. Mainly, generics do
not support specialization (partial or total), nor dependent types
definition/inference. On the other side, generics use a mechanism to
restrict what instanciations are authorized for a given "template".


I wasn't talking about generics - I was talking about managed
templates which support specialization, derivation from the template
parameter type etc.


I know, but I was not sure that Peter Oliphant was aware of the
difference.

Arnaud
MVP - VC

Nov 17 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Steven C. | last post: by
7 posts views Thread by Bob Weiner | last post: by
2 posts views Thread by Mr.Tickle | last post: by
4 posts views Thread by Ana Farcas via .NET 247 | last post: by
reply views Thread by WithPit | last post: by
7 posts views Thread by Bern McCarty | last post: by
25 posts views Thread by Ted | last post: by
3 posts views Thread by Steven T. Hatton | last post: by
1 post views Thread by Korara | last post: by
???
1 post views Thread by Stoney L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.