0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 18:22:50 +01:00

ircd::mods: Add better interface to execute function from imported symbol.

This commit is contained in:
Jason Volk 2017-08-23 15:35:11 -06:00
parent 48045d5b23
commit ec8349bf4f

View file

@ -82,6 +82,7 @@ class sym_ptr
template<class T> const T *get() const;
template<class T> const T *operator->() const;
template<class T> const T &operator*() const;
template<class T, class... args> auto operator()(args&&... a) const;
template<class T> T *get();
template<class T> T *operator->();
@ -95,6 +96,12 @@ template<class T>
struct import
:sym_ptr
{
template<class... args>
auto operator()(args&&... a) const
{
return sym_ptr::operator()<T>(std::forward<args>(a)...);
}
const T *operator->() const { return sym_ptr::operator-><T>(); }
const T &operator*() const { return sym_ptr::operator*<T>(); }
operator const T &() const { return sym_ptr::operator*<T>(); }
@ -187,6 +194,15 @@ ircd::mods::sym_ptr::get()
return reinterpret_cast<T *>(ptr);
}
template<class T,
class... args>
auto
ircd::mods::sym_ptr::operator()(args&&... a)
const
{
return (*get<T>())(std::forward<args>(a)...);
}
template<class T>
const T &
ircd::mods::sym_ptr::operator*()