aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/utility.ixx6
-rw-r--r--libbutl/utility.mxx7
2 files changed, 7 insertions, 6 deletions
diff --git a/libbutl/utility.ixx b/libbutl/utility.ixx
index e17462a..1aa116b 100644
--- a/libbutl/utility.ixx
+++ b/libbutl/utility.ixx
@@ -213,11 +213,11 @@ namespace butl
return nullopt;
}
- template <typename F>
+ template <typename F, typename P>
inline F
- function_cast (void* p)
+ function_cast (P* p)
{
- union { void* p; F f; } r;
+ union { P* p; F f; } r;
r.p = p;
return r.f;
}
diff --git a/libbutl/utility.mxx b/libbutl/utility.mxx
index f944599..5d093ad 100644
--- a/libbutl/utility.mxx
+++ b/libbutl/utility.mxx
@@ -315,11 +315,12 @@ LIBBUTL_MODEXPORT namespace butl
F f_;
};
- // Cleanly cast dlsym() result (void*) to a function pointer.
+ // Cleanly cast between incompatible function types or dlsym() result
+ // (void*) to a function pointer.
//
- template <typename F>
+ template <typename F, typename P>
F
- function_cast (void*);
+ function_cast (P*);
// Call a function if there is an exception.
//