Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2005

Tip: Looking for answers? Try searching our database.

templates and managed code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Oliphant - 11 Oct 2005 02:52 GMT
Is there any plan to support templates with managed code in the (near)
future? For instance, VS.NET 2005... : )
Ronald Laeremans [MSFT] - 11 Oct 2005 03:51 GMT
> 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
Peter Oliphant - 11 Oct 2005 18:12 GMT
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...  : )

>> Is there any plan to support templates with managed code in the (near)
>> future? For instance, VS.NET 2005... : )
[quoted text clipped - 7 lines]
> Ronald Laeremans
> Visual C++ team
Arnaud Debaene - 11 Oct 2005 21:38 GMT
> template< int x >
> class X {} ; // just fine
[quoted text clipped - 7 lines]
> 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
Nishant Sivakumar - 11 Oct 2005 21:40 GMT
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.

Signature

Regards,
Nish [VC++ MVP]

> template< int x >
> class X {} ; // just fine
[quoted text clipped - 19 lines]
>> Ronald Laeremans
>> Visual C++ team
Peter Oliphant - 11 Oct 2005 23:31 GMT
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?

> Managed templates are supported starting VC++ 2005 (and I believe it's
> only for the new syntax).
[quoted text clipped - 26 lines]
>>> Ronald Laeremans
>>> Visual C++ team
Doug Harrison [MVP] - 12 Oct 2005 05:35 GMT
>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.

Signature

Doug Harrison
Visual C++ MVP

adebaene@club-internet.fr - 12 Oct 2005 09:55 GMT
> 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
Nishant Sivakumar - 12 Oct 2005 22:07 GMT
>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.

Signature

Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com

>> Cool that it will be supported in 2005
>
[quoted text clipped - 19 lines]
> Arnaud
> MVP - VC
Arnaud Debaene - 13 Oct 2005 07:28 GMT
>> Beware that managed generics are *NOT* templates, although the
>> (unfortunately IMHO) share most of their syntax. Mainly, generics do
[quoted text clipped - 5 lines]
> 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
Peter Oliphant - 13 Oct 2005 20:55 GMT
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==]

>>> Beware that managed generics are *NOT* templates, although the
>>> (unfortunately IMHO) share most of their syntax. Mainly, generics do
[quoted text clipped - 11 lines]
> Arnaud
> MVP - VC
Nishant Sivakumar - 11 Oct 2005 14:51 GMT
Hey Peter

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

See the section titled "Managed templates"

Signature

Regards,
Nish [VC++ MVP]

> Is there any plan to support templates with managed code in the (near)
> future? For instance, VS.NET 2005... : )

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.