library/win32: conform to the template query signature
This commit is contained in:
parent
eb4a3be352
commit
7e1b14fe98
@ -22,16 +22,26 @@ library::library (const std::experimental::filesystem::path &path):
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
library::library (library &&rhs):
|
||||
m_handle (nullptr)
|
||||
{
|
||||
std::swap (m_handle, rhs.m_handle);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
library&
|
||||
library::operator= (cruft::library &&rhs)
|
||||
{
|
||||
std::swap (m_handle, rhs.m_handle);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
library::~library ()
|
||||
{
|
||||
FreeLibrary (m_handle);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void*
|
||||
library::symbol (const char *name)
|
||||
{
|
||||
return reinterpret_cast<void*> (GetProcAddress (m_handle, name));
|
||||
if (m_handle)
|
||||
FreeLibrary (m_handle);
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
#ifndef __UTIL_LIBRARY_WIN32_HPP
|
||||
#define __UTIL_LIBRARY_WIN32_HPP
|
||||
|
||||
#include <cruft/util/cast.hpp>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <experimental/filesystem>
|
||||
@ -18,9 +20,21 @@ namespace cruft {
|
||||
class library {
|
||||
public:
|
||||
explicit library (const std::experimental::filesystem::path&);
|
||||
library (library const&) = delete;
|
||||
library& operator=(library const&) = delete;
|
||||
library (library&&);
|
||||
library& operator= (library&&);
|
||||
|
||||
~library ();
|
||||
|
||||
void* symbol (const char *name);
|
||||
template <typename FunctionT>
|
||||
FunctionT
|
||||
symbol (const char *name)
|
||||
{
|
||||
return cast::ffs<FunctionT> (
|
||||
GetProcAddress (m_handle, name)
|
||||
);
|
||||
}
|
||||
|
||||
private:
|
||||
HMODULE m_handle;
|
||||
|
Loading…
Reference in New Issue
Block a user