3

"If you have a value type as a function or method parameter, it is normally passed by value. For larger objects, this can cause a performance problem. In Visual Studio2013 and earlier, value types in C++/CX were always passed by value. In Visual Studio 2015 and later, you can pass value types by reference or by value."

That did not work for me, using value_struct& in a function signature had the compiler issue the:

Error C3987 'Set': signature of public member contains native type value_struct&... Works without the reference, Visual Studio 2015

What am I missing?

1 Answer 1

1

I was able to get this to work like this:

public interface class MyDelegate { void MyDelegateMethod(Platform::String^ str, Windows::Foundation::Point *point); } 

.. and in the C# delegate implementation:

public void MyDelegateMethod(string str, out Point p) { ... } 

It's mentioned in the MS page on this stuff (https://msdn.microsoft.com/en-us/library/hh699861.aspx):

You can also use a pointer symbol (*) to pass a value type by reference. The behavior with respect to callers in other languages is the same (callers in C# use the ref keyword), but in the method, the type is a pointer to the value type.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.