From f4353423207c451244ce9118b54ef3dcb28c7f89 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 16 Feb 2016 23:30:16 +0100 Subject: Replace `std::function` with raw function pointer --- src/actual_function.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/actual_function.h b/src/actual_function.h index 8229ccf..ff69a13 100644 --- a/src/actual_function.h +++ b/src/actual_function.h @@ -14,15 +14,17 @@ namespace { template - std::function get_actual_function( - const std::string& symbol_name) { + using function_ptr = Result(*)(Arguments...); - Result (*real_function)(Arguments...) = nullptr; - const void* symbol_address = dlsym(RTLD_NEXT, symbol_name.c_str()); + template + function_ptr get_actual_function( + const std::string& symbol_name) { + const void* symbol_address{ dlsym(RTLD_NEXT, symbol_name.c_str()) }; - std::memcpy(&real_function, &symbol_address, sizeof(symbol_address)); + function_ptr actual_function{}; + std::memcpy(&actual_function, &symbol_address, sizeof(symbol_address)); - return std::function(real_function); + return actual_function; } } -- cgit v1.2.3