STL and Managed C++.NET

P

Peter Oliphant

As I try to create a list of pointers to a garbage collected class I've
created, I'm learning it's not without problems to create an instance of
such list. In fact, so far it won't let me. Apparently STL containers like
'list' are not garbage collected, hence all the managed/unmanaged
incompatibilities come to play (the two, managed and unmanaged code, can't
really be 'mixed freely' as advertised...hehe).

Any place I can look to help with this? I'm trying to do something like
this:

__gc class elementClass {} ;

typedef std::list<__gc class elementClass*> elementClass_Ptr_List ;

__gc class myClass
{
public:
void myMethod()
{
m_List = new elementClass_Ptr_List() ; // ** error here **
}

private:
elementClass_Ptr_List* m_List ;
}

The above compiles UNLESS I try to create an instance of the elementClass
list (the error line). I'd love to just have a 'full' instance of such a
list in myClass's definition (in contrast to a pointer I have to create a
'new' one for), but that fails to compile too.

So, any tutorials on-line on how to use STL with Managed C++.NET (2003)?

[==P==]
 
A

Arnaud Debaene

Peter said:
As I try to create a list of pointers to a garbage collected class
I've created, I'm learning it's not without problems to create an
instance of such list. In fact, so far it won't let me. Apparently
STL containers like 'list' are not garbage collected, hence all the
managed/unmanaged incompatibilities come to play (the two, managed
and unmanaged code, can't really be 'mixed freely' as
advertised...hehe).

STL.NET will be available with Visual Studio 2005, and allow what you want.

For now, you've got to resort to "more manual" methods : Either use a .NET
container (an ArrayList for example), either build a std::list from gcroot
(but this would of course make searching, sorting, etc, a bit more
complicated, since you need to resort to predicate based versions of these
operations).

See
http://www.codeproject.com/managedcpp/whycppcli.asp?df=100&forumid=201953&exp=0&select=1184146
for a disussion on the incoming VC2005, and STL.NET among other things.

Arnaud
MVP - VC
 
M

Marcus Heege

Unfortunately, STL.NET will not ship with .VS 2005 immedeately. It will be
shipped some time after.

At least if the decision has not been changed in the last weeks.

Marcus Heege
 
A

Arnaud Debaene

Marcus said:
Unfortunately, STL.NET will not ship with .VS 2005 immedeately. It
will be shipped some time after.

At least if the decision has not been changed in the last weeks.

Damn'it! Where has this been announced ?

Arnaud
MVP - VC
 
T

Tamas Demjen

Marcus said:
Unfortunately, STL.NET will not ship with .VS 2005 immedeately. It will be
shipped some time after.

At least if the decision has not been changed in the last weeks.

Marcus Heege

Probably, but the STL.NET Beta will ship. There is already have STL.NET
in VS 2005 Beta 2.

Tom
 
C

Carl Daniel [VC++ MVP]

Tamas said:
Probably, but the STL.NET Beta will ship. There is already have
STL.NET in VS 2005 Beta 2.

Those files actually weren't supposed to be included in Beta 2 even, they
just weren't removed from the install image until after beta 2 shipped.
Don't expect to see STL.NET in the release image for VS2005 - it'll be
released sometime after (hopefully not too long!)

-cd
 
W

Willy Denoyette [MVP]

Tamas Demjen said:
Probably, but the STL.NET Beta will ship. There is already have STL.NET in
VS 2005 Beta 2.

Tom

Yes, but they were included by mistake, later builds have the bits removed.

Here is what's been posted to the VC++ forum some time ago:
<
STL/CLR (STL .NET) is not supported in Beta 2. We are planning to release
the beta version of STL/CLR at the time of VS 2005 final release, and the
final release of STL/CLR via the web in 2006.

Anson Tsao
Lead Program Manager
Microsoft Visual C++
Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top