--- a/doc/manual/callbacks.texi Mon May 10 16:41:20 2010 +0200
+++ b/doc/manual/callbacks.texi Mon May 10 21:10:15 2010 -0700
@@ -380,8 +380,12 @@
So in the above example, we have a declared a callback named "one" that will
eventually hold a function pointer. The signature of the function that it will
hold must return double and must support two double arguments. If one tries
-to pass a function whose signature does not match the declared callback, a
-run-time NS_FATAL_ERROR will be raised.
+to pass a function whose signature does not match the declared callback,
+a compilation error will occur. Also, if one tries to assign to a callback
+an incompatible one, compilation will succeed but a run-time
+NS_FATAL_ERROR will be raised. The sample program
+@command{samples/main-callback.cc} demonstrates both of these error cases
+at the end of the @command{main()} program.
Now, we need to tie together this callback instance and the actual target function
(CbOne). Notice above that CbOne has the same function signature types as the
--- a/samples/main-callback.cc Mon May 10 16:41:20 2010 +0200
+++ b/samples/main-callback.cc Mon May 10 21:10:15 2010 -0700
@@ -54,5 +54,19 @@
//int retTwoNull = two (20.0);
NS_ASSERT (two.IsNull ());
+#if 0
+ // The below type mismatch between CbOne() and callback two will fail to
+ // compile if enabled in this program.
+ two = MakeCallback (&CbOne);
+#endif
+
+#if 0
+ // This is a slightly different example, in which the code will compile
+ // but because callbacks are type-safe, will cause a fatal error at runtime
+ // (the difference here is that Assign() is called instead of operator=)
+ Callback<void, float> three;
+ three.Assign (MakeCallback (&CbOne));
+#endif
+
return 0;
}