473,804 Members | 3,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with std::stable_sor t on a std::vector<gcr oot<T> >

Has anyone ever tried to sort a Standard Library container of gcroots? I
have run into the problem that somewhere deep in the Library logic (in
line 338 of <memory>, to be precise) the destructor of a class
_Temp_iterator tries to obtain the address of a gcroot, but fails
because gcroot::operato r& is private.

--
Gerhard Menzl

#dogma int main ()

Humans may reply by replacing the obviously faked part of my e-mail
address with "kapsch".
Nov 17 '05 #1
5 2640

"Gerhard Menzl" <ge***********@ spambucket.net> skrev i meddelandet
news:41******** @news.kapsch.co .at...
Has anyone ever tried to sort a Standard Library container of gcroots?
I have run into the problem that somewhere deep in the Library logic
(in line 338 of <memory>, to be precise) the destructor of a class
_Temp_iterator tries to obtain the address of a gcroot, but fails
because gcroot::operato r& is private.


An object stored in a standard container must be CopyConstructib le,
which includes having a public operator& returning the address of the
object.
Bo Persson
Nov 17 '05 #2
> Has anyone ever tried to sort a Standard Library container of gcroots? I
have run into the problem that somewhere deep in the Library logic (in
line 338 of <memory>, to be precise) the destructor of a class
_Temp_iterator tries to obtain the address of a gcroot, but fails
because gcroot::operato r& is private.


Although you can easely avoid this restriction I should point out that
gcroot isn't as light as pointers. Its copy involves "GCHandle::Allo c" -
registration of managed pointer handler. The better way is to have gcroot in
some object which is not moved around.
--
Vladimir Nesterovsky
e-mail: vl******@nester ovsky-bros.com
home: http://www.nesterovsky-bros.com
Nov 17 '05 #3
Vladimir Nesterovsky wrote:
Although you can easely avoid this restriction I should point out that
gcroot isn't as light as pointers. Its copy involves "GCHandle::Allo c" -
registration of managed pointer handler. The better way is to have gcroot in
some object which is not moved around.


I am well aware that there is a lot more going on behind the scenes when
copying GCHandles than with pointers, and I don't have a performance
problem with it. What I do have a problem with is having to add yet
another wrapper whenever I want a Standard Library container of managed
types. I also don't see how I could prevent such a wrapper object from
being moved around: as soon as it is put into a standard container, it
(and the GCHandle it wraps) *will* be copied. The only way to prevent
this would be to not using standard containers of managed objects in the
first place.

Interestingly, std::sort does not exhibit the described problem.

--
Gerhard Menzl

#dogma int main ()

Humans may reply by replacing the obviously faked part of my e-mail
address with "kapsch".
Nov 17 '05 #4
Bo Persson wrote:
An object stored in a standard container must be CopyConstructib le,
which includes having a public operator& returning the address of the
object.


Thanks for pointing this out. This seems like a major design flaw of
gcroot to me. After all, gcroot is described as a way of storing managed
objects in Standard Library containers. See
http://www.codeproject.com/managedcp...asp?print=true, for example.

--
Gerhard Menzl

#dogma int main ()

Humans may reply by replacing the obviously faked part of my e-mail
address with "kapsch".
Nov 17 '05 #5

"Gerhard Menzl" <ge***********@ spambucket.net> skrev i meddelandet
news:41******** @news.kapsch.co .at...
Bo Persson wrote:
An object stored in a standard container must be CopyConstructib le,
which includes having a public operator& returning the address of the
object.


Thanks for pointing this out. This seems like a major design flaw of
gcroot to me. After all, gcroot is described as a way of storing
managed objects in Standard Library containers. See
http://www.codeproject.com/managedcp...asp?print=true, for
example.


That's interesting. It's sort of a solution that almost works. :-)

Guess that is the best you can do under the circumstances.
Bo Persson
Nov 17 '05 #6

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

Similar topics

0
1343
by: Gerhard Menzl | last post by:
The following Managed C++ code when built using Visual Studio .NET 2003: #include <vector> #include <vcclr.h> __gc class Tester { public: typedef gcroot<Object*> TestPtr;
0
9708
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9588
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10340
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
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
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2999
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.