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

Started by
5 comments, last by Muzzy A 10 years, 8 months ago

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?

Advertisement

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.

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.

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.

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.

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.

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

This topic is closed to new replies.

Advertisement