[Lldb-commits] [lldb] r217718 - std::function is a better choice than a raw function pointer here. You probably still want to be careful about cleaning up stuff you captured, but it's not like a function pointer wasn't going to let you shoot yourself in the foot given enough dedication.

Enrico Granata egranata at apple.com
Fri Sep 12 15:56:52 PDT 2014


Author: enrico
Date: Fri Sep 12 17:56:52 2014
New Revision: 217718

URL: http://llvm.org/viewvc/llvm-project?rev=217718&view=rev
Log:
std::function is a better choice than a raw function pointer here. You probably still want to be careful about cleaning up stuff you captured, but it's not like a function pointer wasn't going to let you shoot yourself in the foot given enough dedication.

Modified:
    lldb/trunk/include/lldb/Utility/CleanUp.h

Modified: lldb/trunk/include/lldb/Utility/CleanUp.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/CleanUp.h?rev=217718&r1=217717&r2=217718&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/CleanUp.h (original)
+++ lldb/trunk/include/lldb/Utility/CleanUp.h Fri Sep 12 17:56:52 2014
@@ -11,6 +11,7 @@
 #define liblldb_CleanUp_h_
 
 #include "lldb/lldb-public.h"
+#include <functional>
 
 namespace lldb_utility {
 
@@ -57,7 +58,7 @@ class CleanUp
 {
 public:
     typedef T value_type;
-    typedef R (*CallbackType)(value_type);
+    typedef std::function<R(value_type)> CallbackType;
 
     //----------------------------------------------------------------------
     // Constructor that sets the current value only. No values are 
@@ -188,7 +189,7 @@ class CleanUp2
 {
 public:
     typedef T value_type;
-    typedef R (*CallbackType)(value_type, A0);
+    typedef std::function<R(value_type,A0)> CallbackType;
     
     //----------------------------------------------------------------------
     // Constructor that sets the current value only. No values are 





More information about the lldb-commits mailing list