Skip to content

Commit

Permalink
Support noexcept stripping
Browse files Browse the repository at this point in the history
  • Loading branch information
vapourismo committed Jul 17, 2023
1 parent aff3361 commit e0e4b6b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/luwra/internal/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,35 @@ template <typename Klass, typename Ret, typename... Args>
struct CallableInfo<Ret (Klass::*)(Args...) const volatile>:
CallableInfo<Ret (Args...)> {};

#if __cplusplus >= 201703L

// Function pointer
template <typename Ret, typename... Args>
struct CallableInfo<Ret (*)(Args...) noexcept>:
CallableInfo<Ret (Args...)> {};

// Method pointer
template <typename Klass, typename Ret, typename... Args>
struct CallableInfo<Ret (Klass::*)(Args...) noexcept>:
CallableInfo<Ret (Args...)> {};

// Method pointer on const-qualified this
template <typename Klass, typename Ret, typename... Args>
struct CallableInfo<Ret (Klass::*)(Args...) const noexcept>:
CallableInfo<Ret (Args...)> {};

// Method pointer on volatile-qualified this
template <typename Klass, typename Ret, typename... Args>
struct CallableInfo<Ret (Klass::*)(Args...) volatile noexcept>:
CallableInfo<Ret (Args...)> {};

// Method pointer on const-volatile-qualified this
template <typename Klass, typename Ret, typename... Args>
struct CallableInfo<Ret (Klass::*)(Args...) const volatile noexcept>:
CallableInfo<Ret (Args...)> {};

#endif

// Remove const qualification
template <typename Callable>
struct CallableInfo<const Callable>:
Expand Down
24 changes: 24 additions & 0 deletions lib/luwra/wrappers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,30 @@ namespace internal {
struct MemberWrapper<Ret (BaseKlass::*)(Args...), Klass>:
MethodWrapperImpl<Ret (BaseKlass::*)(Args...), Klass>::Implementation {};

#if __cplusplus >= 201703L

// Wrap methods that expect 'this' to be const-volatile-qualified.
template <typename Klass, typename BaseKlass, typename Ret, typename... Args>
struct MemberWrapper<Ret (BaseKlass::*)(Args...) const volatile noexcept, Klass>:
MethodWrapperImpl<Ret (BaseKlass::*)(Args...) const volatile noexcept, Klass>::Implementation {};

// Wrap methods that expect 'this' to be const-qualified.
template <typename Klass, typename BaseKlass, typename Ret, typename... Args>
struct MemberWrapper<Ret (BaseKlass::*)(Args...) const noexcept, Klass>:
MethodWrapperImpl<Ret (BaseKlass::*)(Args...) const noexcept, Klass>::Implementation {};

// Wrap methods that expect 'this' to be volatile-qualified.
template <typename Klass, typename BaseKlass, typename Ret, typename... Args>
struct MemberWrapper<Ret (BaseKlass::*)(Args...) volatile noexcept, Klass>:
MethodWrapperImpl<Ret (BaseKlass::*)(Args...) volatile noexcept, Klass>::Implementation {};

// Wrap methods that expect 'this' to be unqualified.
template <typename Klass, typename BaseKlass, typename Ret, typename... Args>
struct MemberWrapper<Ret (BaseKlass::*)(Args...) noexcept, Klass>:
MethodWrapperImpl<Ret (BaseKlass::*)(Args...) noexcept, Klass>::Implementation {};

#endif

// Wrap const-qualified field, provides only the getter.
template <typename Klass, typename BaseKlass, typename FieldType>
struct MemberWrapper<const FieldType BaseKlass::*, Klass> {
Expand Down

0 comments on commit e0e4b6b

Please sign in to comment.