Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


std::vector<> vs cli::array<>


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Muzzy A   Members   -  Reputation: 644

Like
0Likes
Like

Posted 02 August 2013 - 10:32 PM

Hey I've been messing around with CLR stuff and noticed the 'array' object in there. I looked online for performance comparisons between that and the standard array in c++ and the std::vector class, but couldn't find anything useful.

 

Does anyone know if this class basically a .NET version of the vector class? If it's faster/slower than std::vector? Faster/Slower than standard C++ arrays?

 

 

 

Oh and on a side note, the carets they use '^' are smart pointers right? are these compatible with normal pointers?


Edited by Muzzy A, 02 August 2013 - 10:38 PM.


Sponsor:

#2 Martins Mozeiko   Crossbones+   -  Reputation: 1422

Like
1Likes
Like

Posted 02 August 2013 - 11:31 PM

They are completely different beasts.

 
CLI array is not a "standard C++ array. They are managed arrays. It's like new [] operator in C++, but for managed heap. cli::array allocates memory in managed heap and garbage collects it to free the memory. 

std::vector allocates its memory from regular C++ heap and frees it when it goes out of scope.

 

^ is not for smart pointers. It is for managed pointers - they get garbage collected to free the memory.



#3 Muzzy A   Members   -  Reputation: 644

Like
-1Likes
Like

Posted 03 August 2013 - 12:02 AM

The fact that it's managed makes me want to remove it from my computer =P

 

Thanks for the explanation. I probably wont be using any cli::arrays in the near future lol. I enjoy managing my own memory, I have an attachment to it.



#4 Washu   Senior Moderators   -  Reputation: 5358

Like
0Likes
Like

Posted 03 August 2013 - 02:51 AM

So you're trying to mess around with the "CLR" without using managed memory, because you think you can do better. Sounds like you're wasting a great deal of your time on a silly idea.


In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


#5 Nypyren   Crossbones+   -  Reputation: 4494

Like
1Likes
Like

Posted 03 August 2013 - 03:07 AM

C++/CLI should never be used "for fun". It's there to allow for interop layers between native C and C++ and full-fledged .Net (typically C#). Writing an entire app in it is possible, but just because it's possible doesn't mean it's a good idea.

#6 Washu   Senior Moderators   -  Reputation: 5358

Like
0Likes
Like

Posted 03 August 2013 - 03:20 AM

C++/CLI should never be used "for fun". It's there to allow for interop layers between native C and C++ and full-fledged .Net (typically C#). Writing an entire app in it is possible, but just because it's possible doesn't mean it's a good idea.

Well, I mean, it IS a first class .net language.

 

Of course, that is like saying "Scheme is turing complete." Doesn't mean you should use it :D


In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


#7 Muzzy A   Members   -  Reputation: 644

Like
0Likes
Like

Posted 03 August 2013 - 03:33 AM

I'm just diving into CLR because I noticed that it had functions and classes that did things for you that make alot of things quite simple,specifically the Console methods and classes. I have no intent on making a full app with it, I just found it interesting, I didn't want a heated argument about CLR vs C++.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS