Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
Revision 924:f4a901a3e6cd, committed 2015-11-26
- Comitter:
- rgrover1
- Date:
- Thu Nov 26 12:52:04 2015 +0000
- Parent:
- 923:ca1964e56ddf
- Child:
- 925:59fa57e19fa4
- Commit message:
- Synchronized with git rev 57e69cb0
Author: Vincent Coubard
Add safe bool conversion to ninic function pointer semantic
Changed in this revision
| ble/FunctionPointerWithContext.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/ble/FunctionPointerWithContext.h Thu Nov 26 12:52:04 2015 +0000
+++ b/ble/FunctionPointerWithContext.h Thu Nov 26 12:52:04 2015 +0000
@@ -111,6 +111,19 @@
}
}
+ typedef void (FunctionPointerWithContext::*bool_type)() const;
+
+ /**
+ * implementation of safe bool operator
+ */
+ operator bool_type() const {
+ if(_function || _memberFunctionAndPointer._object) {
+ return &FunctionPointerWithContext::trueValue;
+ }
+
+ return 0;
+ }
+
/**
* Set up an external FunctionPointer as a next in the chain of related
* callbacks. Invoking call() on the head FunctionPointer will invoke all
@@ -156,6 +169,12 @@
}
}
+ /**
+ * @brief True value used in conversion to bool, this function is useless
+ * beside this usage
+ */
+ void trueValue() const {}
+
struct MemberFunctionAndPtr {
/*
* Forward declaration of a class and a member function to this class.
