library: force typing for symbol queries

This commit is contained in:
Danny Robson 2018-05-03 21:22:41 +10:00
parent 1350ea93c7
commit 93ddd4c11d
2 changed files with 10 additions and 10 deletions

View File

@ -16,7 +16,6 @@
#include "library_posix.hpp"
#include <dlfcn.h>
#include <stdexcept>
@ -46,11 +45,3 @@ library_posix::~library_posix ()
if (m_handle)
dlclose (m_handle);
}
///////////////////////////////////////////////////////////////////////////////
void*
library_posix::symbol (const char *name)
{
return dlsym (m_handle, name);
}

View File

@ -19,6 +19,8 @@
#include <experimental/filesystem>
#include <dlfcn.h>
namespace util {
namespace detail {
class library_posix {
@ -30,7 +32,14 @@ namespace util {
library_posix (const library_posix&) = delete;
library_posix& operator= (const library_posix&) = delete;
void* symbol (const char *name);
template <typename FunctionT>
FunctionT
symbol (const char *name)
{
return reinterpret_cast<FunctionT> (
dlsym (m_handle, name)
);
}
private:
void *m_handle;