Commit ea55f97e authored by Davis King's avatar Davis King

Previously, if you accidentally tried to copy between any_function instances

with incompatible function signatures you got a really confusing error message
from the compiler.  This change makes it so you get a much more informative
error message.
parent cfc6e83d
...@@ -13,6 +13,12 @@ ...@@ -13,6 +13,12 @@
#define DLIB_ANY_FUNCTION_RETURN return #define DLIB_ANY_FUNCTION_RETURN return
#include "any_function_impl.h" #include "any_function_impl.h"
#undef DLIB_ANY_FUNCTION_RETURN #undef DLIB_ANY_FUNCTION_RETURN
private:
// You get a compiler error about this function being private if you try to assign
// or copy between any_functions with different types. You must only copy between
// any_functions that represent functions with the same signature.
template <typename T, typename U> any_function(const any_function<T,U>&);
}; };
// The case where function_type has a void return type // The case where function_type has a void return type
...@@ -22,6 +28,12 @@ ...@@ -22,6 +28,12 @@
#define DLIB_ANY_FUNCTION_RETURN #define DLIB_ANY_FUNCTION_RETURN
#include "any_function_impl.h" #include "any_function_impl.h"
#undef DLIB_ANY_FUNCTION_RETURN #undef DLIB_ANY_FUNCTION_RETURN
private:
// You get a compiler error about this function being private if you try to assign
// or copy between any_functions with different types. You must only copy between
// any_functions that represent functions with the same signature.
template <typename T> any_function(const any_function<T>&);
}; };
#undef DLIB_ANY_FUNCTION_ARG_LIST #undef DLIB_ANY_FUNCTION_ARG_LIST
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment