type_caster<std::function>: allow None values in both directions
diff --git a/example/example-callbacks.cpp b/example/example-callbacks.cpp
index afb864d..a5a3b83 100644
--- a/example/example-callbacks.cpp
+++ b/example/example-callbacks.cpp
@@ -38,7 +38,10 @@
int dummy_function(int i) { return i + 1; }
int dummy_function2(int i, int j) { return i + j; }
std::function<int(int)> roundtrip(std::function<int(int)> f) {
- std::cout << "roundtrip.." << std::endl;
+ if (!f)
+ std::cout << "roundtrip (got None).." << std::endl;
+ else
+ std::cout << "roundtrip.." << std::endl;
return f;
}
diff --git a/example/example-callbacks.py b/example/example-callbacks.py
index 89f83a1..68a485a 100755
--- a/example/example-callbacks.py
+++ b/example/example-callbacks.py
@@ -68,6 +68,8 @@
test_dummy_function(dummy_function)
test_dummy_function(roundtrip(dummy_function))
+if roundtrip(None) is not None:
+ print("Problem!")
test_dummy_function(lambda x: x + 2)
try:
diff --git a/example/example-callbacks.ref b/example/example-callbacks.ref
index 72f751a..c6f8f53 100644
--- a/example/example-callbacks.ref
+++ b/example/example-callbacks.ref
@@ -30,6 +30,7 @@
Move constructions: True
argument matches dummy_function
eval(1) = 2
+roundtrip (got None)..
roundtrip..
argument matches dummy_function
eval(1) = 2