This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Description
Right now, it is not exactly clear when or how to pass references
void use_reference(int *ptr)
{
//do I reference here?
auto int *ref = mc_reference(ptr);
}
int main()
{
auto int *ptr = mc_managed_alloc(sizeof(int), 1, NULL);
//or here?
use_reference(mc_reference(ptr));
}
Although this is up to the programmer to decide, it would still be useful to have a standard/safer way to do this, to avoid forgetting to call mc_reference.
The top example would probably work the best, as with the second method you have to manually call release in the use_reference function to release the reference, unless you store the reference into a new pointer like so
void use_reference(int *ptr)
{
auto int *ref = ptr;
}
int main()
{
int *ptr = mc_managed_alloc(sizeof(int), 1, NULL);
use_reference(mc_reference(ptr));
}