mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
ircd::mods: Improve return type deduction.
This commit is contained in:
parent
c5d993f7c5
commit
6df8fcf244
3 changed files with 15 additions and 11 deletions
|
@ -36,8 +36,8 @@ struct ircd::mods::import
|
|||
void reload();
|
||||
|
||||
public:
|
||||
template<class... args> auto operator()(args&&... a) const;
|
||||
template<class... args> auto operator()(args&&... a);
|
||||
template<class... args> decltype(auto) operator()(args&&... a) const;
|
||||
template<class... args> decltype(auto) operator()(args&&... a);
|
||||
|
||||
const T *operator->() const;
|
||||
const T &operator*() const;
|
||||
|
@ -157,22 +157,24 @@ const
|
|||
|
||||
template<class T>
|
||||
template<class... args>
|
||||
auto
|
||||
decltype(auto)
|
||||
ircd::mods::import<T>::operator()(args&&... a)
|
||||
{
|
||||
if(unlikely(!*this))
|
||||
reload();
|
||||
|
||||
return sym_ptr::operator()<T>(std::forward<args>(a)...);
|
||||
using R = decltype(get<T>()(a...));
|
||||
return sym_ptr::operator()<T, R>(std::forward<args>(a)...);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template<class... args>
|
||||
auto
|
||||
decltype(auto)
|
||||
ircd::mods::import<T>::operator()(args&&... a)
|
||||
const
|
||||
{
|
||||
return sym_ptr::operator()<T>(std::forward<args>(a)...);
|
||||
using R = decltype(get<T>()(a...));
|
||||
return sym_ptr::operator()<T, R>(std::forward<args>(a)...);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
|
|
@ -30,12 +30,12 @@ class ircd::mods::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, class R, class... args> R operator()(args&&... a) const;
|
||||
|
||||
template<class T> T *get();
|
||||
template<class T> T *operator->();
|
||||
template<class T> T &operator*();
|
||||
template<class T, class... args> auto operator()(args&&... a);
|
||||
template<class T, class R, class... args> R operator()(args&&... a);
|
||||
|
||||
explicit sym_ptr(mod &, const string_view &symname);
|
||||
sym_ptr(module, const string_view &symname);
|
||||
|
@ -44,8 +44,9 @@ class ircd::mods::sym_ptr
|
|||
};
|
||||
|
||||
template<class T,
|
||||
class R,
|
||||
class... args>
|
||||
auto
|
||||
R
|
||||
ircd::mods::sym_ptr::operator()(args&&... a)
|
||||
{
|
||||
return (operator*<T>())(std::forward<args>(a)...);
|
||||
|
@ -79,8 +80,9 @@ ircd::mods::sym_ptr::get()
|
|||
}
|
||||
|
||||
template<class T,
|
||||
class R,
|
||||
class... args>
|
||||
auto
|
||||
R
|
||||
ircd::mods::sym_ptr::operator()(args&&... a)
|
||||
const
|
||||
{
|
||||
|
|
|
@ -193,7 +193,7 @@ _console_command(opt &out,
|
|||
|
||||
const auto &ptr{cmd->ptr};
|
||||
using prototype = bool (struct opt &, const string_view &);
|
||||
return ptr.operator()<prototype>(out, args);
|
||||
return ptr.operator()<prototype, bool>(out, args);
|
||||
}
|
||||
|
||||
/// This function may be linked and called by those wishing to execute a
|
||||
|
|
Loading…
Reference in a new issue