The value of ^ variables in C ++ / CX

I just returned to C ++ for a game-related project for Windows 8 / RT after many years of absence in favor of C #.

Working with the generated project project skeleton I came across method signatures, as shown below. Can someone enlighten me what should do?

Concurrency::task<Platform::Array<byte>^> ReadDataAsync(Platform::String^ filename) 
+7
source share
3 answers

In C ++ / CX, a T^ is a handle to an object T This is an efficient smart pointer that owns a reference to an object pointing to an object, with some additional bonus features provided by the compiler.

You can find out all about hats in the article, Types that Hats Wear.

+6
source

Apparently, it is called the handle-to-object operator.

The handle-to-object ^ operator is known as a hat and is basically a C ++ smart pointer. The memory that it points to is automatically destroyed when the last hat goes out of scope or is explicitly set to nullptr.

According to: https://msdn.microsoft.com/en-us/library/hh699870.aspx . (From the "Memory Management" section of this page.

0
source

The ^ character is an object handle.

For example, String^ s; declares a handle to the object 'String'.

http://en.wikipedia.org/wiki/C%2B%2B/CLI#Handles

-one
source

All Articles