Attempt to get C++17 work compiling for VS 2019

This commit is contained in:
Jason Turner 2019-04-20 12:09:24 -06:00
parent b0c1483f70
commit b7e26b9076
2 changed files with 104 additions and 83 deletions

View File

@ -4,13 +4,15 @@
#include <type_traits> #include <type_traits>
namespace chaiscript::dispatch::detail { namespace chaiscript::dispatch::detail {
template<typename... Param> template<typename... Param>
struct Function_Params struct Function_Params
{ {
}; };
template<typename Ret, typename Params, bool IsNoExcept = false, bool IsMember = false, bool IsMemberObject = false, bool IsObject = false> template<typename Ret, typename Params, bool IsNoExcept = false, bool IsMember = false, bool IsMemberObject = false, bool IsObject = false>
struct Function_Signature { struct Function_Signature
{
using Param_Types = Params; using Param_Types = Params;
using Return_Type = Ret; using Return_Type = Ret;
constexpr static const bool is_object = IsObject; constexpr static const bool is_object = IsObject;
@ -110,15 +112,34 @@ namespace chaiscript::dispatch::detail {
template<typename Ret, typename Class> template<typename Ret, typename Class>
Function_Signature(Ret(Class::*f))->Function_Signature<Ret, Function_Params<Class &>, true, true, true>; Function_Signature(Ret(Class::*f))->Function_Signature<Ret, Function_Params<Class &>, true, true, true>;
// primary template handles types that have no nested ::type member:
template<class, class = std::void_t<>>
struct has_call_operator : std::false_type
{
};
// specialization recognizes types that do have a nested ::type member:
template<class T>
struct has_call_operator<T, std::void_t<decltype(&T::operator())>> : std::true_type
{
};
template<typename Func> template<typename Func>
Function_Signature(Func &&) -> Function_Signature< auto function_signature(const Func &f)
{
if constexpr (has_call_operator<Func>::value) {
return Function_Signature<
typename decltype(Function_Signature{ &std::decay_t<Func>::operator() })::Return_Type, typename decltype(Function_Signature{ &std::decay_t<Func>::operator() })::Return_Type,
typename decltype(Function_Signature{ &std::decay_t<Func>::operator() })::Param_Types, typename decltype(Function_Signature{ &std::decay_t<Func>::operator() })::Param_Types,
decltype(Function_Signature{ &std::decay_t<Func>::operator() })::is_noexcept, decltype(Function_Signature{ &std::decay_t<Func>::operator() })::is_noexcept,
false, false,
false, false,
true true>{};
>; } else {
return Function_Signature{ f };
}
} }
}// namespace chaiscript::dispatch::detail
#endif #endif

View File

@ -87,7 +87,7 @@ namespace chaiscript
template<typename T> template<typename T>
Proxy_Function fun(T &&t) Proxy_Function fun(T &&t)
{ {
return dispatch::detail::make_callable(std::forward<T>(t), dispatch::detail::Function_Signature{t}); return dispatch::detail::make_callable(std::forward<T>(t), dispatch::detail::function_signature(t));
} }