Sign in to follow this  
Muzzy A

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

Recommended Posts

Muzzy A    737

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

Share this post


Link to post
Share on other sites
bubu LV    1436

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.

Share this post


Link to post
Share on other sites
Muzzy A    737

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.

Share this post


Link to post
Share on other sites
Washu    7829

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.

Share this post


Link to post
Share on other sites
Nypyren    12063
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.

Share this post


Link to post
Share on other sites
Washu    7829

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

Share this post


Link to post
Share on other sites
Muzzy A    737

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++.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this