[Bf-blender-cvs] [787e97057ae] functions: return function body instead of bool

Jacques Lucke noreply at git.blender.org
Thu Aug 1 18:23:41 CEST 2019


Commit: 787e97057aea759ee56b2a210a19ad0c553a8ab3
Author: Jacques Lucke
Date:   Thu Aug 1 17:18:07 2019 +0200
Branches: functions
https://developer.blender.org/rB787e97057aea759ee56b2a210a19ad0c553a8ab3

return function body instead of bool

===================================================================

M	source/blender/functions/core/function.hpp

===================================================================

diff --git a/source/blender/functions/core/function.hpp b/source/blender/functions/core/function.hpp
index 1d798de78d1..b1c9fa34183 100644
--- a/source/blender/functions/core/function.hpp
+++ b/source/blender/functions/core/function.hpp
@@ -85,8 +85,9 @@ class Function final : public RefCountedBase {
   /**
    * Add another implementation to the function. Every type of implementation can only be added
    * once. Future calls with the same type are ignored.
+   * Returns the pointer to the body when it was newly created, nullptr otherwise.
    */
-  template<typename T, typename... Args> bool add_body(Args &&... args);
+  template<typename T, typename... Args> T *add_body(Args &&... args);
 
   /**
    * Get the number of inputs.
@@ -185,7 +186,7 @@ template<typename T> inline T &Function::body() const
   return *(T *)m_bodies[T::FUNCTION_BODY_ID];
 }
 
-template<typename T, typename... Args> inline bool Function::add_body(Args &&... args)
+template<typename T, typename... Args> inline T *Function::add_body(Args &&... args)
 {
   STATIC_ASSERT_BODY_TYPE(T);
 
@@ -194,10 +195,10 @@ template<typename T, typename... Args> inline bool Function::add_body(Args &&...
     T *new_body = new T(std::forward<Args>(args)...);
     new_body->set_owner(this);
     m_bodies[T::FUNCTION_BODY_ID] = new_body;
-    return true;
+    return new_body;
   }
   else {
-    return false;
+    return nullptr;
   }
 }



More information about the Bf-blender-cvs mailing list