473,549 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1810
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*******@Roun dTripInc.com> wrote in message
news:OU******** ******@TK2MSFTN GP10.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******** *******@TK2MSFT NGP10.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*******@Roun dTripInc.com> wrote in message
news:u7******** ******@TK2MSFTN GP12.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******** *******@TK2MSFT NGP10.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.as ianetindia.com> wrote in message
news:u1******** ********@TK2MSF TNGP12.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*******@Roun dTripInc.com> wrote in message
news:u7******** ******@TK2MSFTN GP12.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******** *******@TK2MSFT NGP10.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*******@Roun dTripInc.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
(unfortunate ly 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******@clu b-internet.fr> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.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

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

Similar topics

7
2372
by: Steven C. | last post by:
When you compile a cpp program that includes a template class in a .h file where does the compiled code go for that templated class? If it went in the obj for the cpp program seems to me you could end up with multiple templates of the same type if the .h file was included in multiple .cpp. Seems more straight forward that it would be put in...
7
1593
by: Bob Weiner | last post by:
Hi, Forgive me if this has already been discussed but does C# have a construct like C++ templates? bob
2
3092
by: Mr.Tickle | last post by:
So whats the deal here regarding Generics in the 2004 release and templates currently in C++?
4
1163
by: Ana Farcas via .NET 247 | last post by:
hello, i have an old library i need to port to .net. the old library is written in visual c++ 6.0 and uses templated classes. if i compile the library (after having gone through the conversion wizard), i get errors with the definitions of the templated classes. below are some examples. template<class base, class client>...
0
922
by: WithPit | last post by:
I am creating a wrapper around an existing C++ library. A lot of classes and methods are wrapped but there are still some little problems. One of the problem is the use of templates in C++ which does not exists in managed languages like C# (i am talking here about C# 1.1 version, not 2.0 which has some generics options). How can i get rid...
7
1124
by: Bern McCarty | last post by:
We have some large mixed .dlls. The percentage of code that is managed is small relative to the percentage of native code. We generally want to favor native callers. But I am struggling with the phenomenon where the mere use inclusion of headers that contain templates in /CLR compilands seems to result in methods of template instations...
1
1308
by: Greg | last post by:
Referring to Managed: why do templates require an explicit copy constructor to be defined in order to use gcnew whereas simply declaring an object as a local (still uses managed heap of course) does not require the template to have a default constructor defined? -- Greg McPherran www.McPherran.com
25
3302
by: Ted | last post by:
I'm putting the posts that follow here (hopefully they will follow here!) because they were rejected in comp.lang.c++.moderated. It behooves anyone reading them to first read the the thread of the same subject in clc++m to get the more of the context. Ted
3
3999
by: Steven T. Hatton | last post by:
Has anybody here used explicit instantiation of templates? Has it worked well? Are there any issues to be aware of? -- NOUN:1. Money or property bequeathed to another by will. 2. Something handed down from an ancestor or a predecessor or from the past: a legacy of religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,...
0
7551
marktang
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...
0
7477
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...
0
7750
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7991
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5396
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3524
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...
1
1971
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
0
790
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.