From 5790ef690106ba481aa4992c75bc752a140915a1 Mon Sep 17 00:00:00 2001 From: Kaido Kert Date: Wed, 6 Jan 2016 00:12:04 -0800 Subject: [PATCH] Tiny fix for misnamed macro, add a compile-test for it --- delegate.hpp | 2 +- test/main.cpp | 8 ++++++-- test/routines.cpp | 4 ++++ test/routines.hpp | 6 ++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/delegate.hpp b/delegate.hpp index 45a7547..a118201 100644 --- a/delegate.hpp +++ b/delegate.hpp @@ -154,7 +154,7 @@ using detail::Delegate; #undef CB_FORWARD #define __CB_DELEGATE_INIT(instance, func) decltype(CB::detail::create_delegate(func))::bind(instance) -#define __CB_DELEGATE_FF(func) decltype(CB::detail::create_delegate(func))::bind() +#define __CB_DELEGATE_INIT_FF(func) decltype(CB::detail::create_delegate(func))::bind() #define CB_DELEGATE_INIT __CB_DELEGATE_INIT #define CB_DELEGATE_FF __CB_DELEGATE_INIT_FF diff --git a/test/main.cpp b/test/main.cpp index c681f5a..eb80437 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -60,8 +60,12 @@ int main(int argc, char **argv) printf("%d\n", b3(5)); } + { + printf("\n"); + E d = create_delegate_freefunction(); + int val = 41; + printf("%d %d\n",d(val), val); + } return 0; } - - diff --git a/test/routines.cpp b/test/routines.cpp index f30f111..f8e04c8 100644 --- a/test/routines.cpp +++ b/test/routines.cpp @@ -19,3 +19,7 @@ D create_delegate(Value &v) return d; } +E create_delegate_freefunction() { + E d = CB_DELEGATE_FF(increment); + return d; +} diff --git a/test/routines.hpp b/test/routines.hpp index e5c77a1..3447990 100644 --- a/test/routines.hpp +++ b/test/routines.hpp @@ -5,6 +5,7 @@ using C = CB::StaticClosure; using C1 = CB::StaticClosure; using D = CB::Delegate; +using E = CB::Delegate; struct Value { @@ -17,6 +18,11 @@ struct Value { }; +inline int increment(int &val) { + return val++; +} + C create_closure(int init, const char *text); C1 create_closure2(int init, const char *text); D create_delegate(Value &v); +E create_delegate_freefunction();