Template Function Karana::Core::createSharedPtrDiscard

Template Function Karana::Core::createSharedPtrDiscard#

Function Documentation#

template<typename T, typename R, typename ...Args>
auto Karana::Core::createSharedPtrDiscard(R (*f)(Args...))#

Registers a discard for a Python object using a shared pointer on create. This works by using a weakref.finalize function that calls the discard method if the use count of the shared pointer is <= 2.

Template Parameters:
  • T – The type used in the discard function.

  • R – The return type from f.

  • Args – The arguments used in f to create the object.

Parameters:

f – - The function used to create the object.

Returns:

A Python weakref of type R that will call discard when it goes out of scope.