AuROXTL/Include/auROXTL/Utility/auInvoke.hpp

42 lines
1.0 KiB
C++

/***
Copyright (C) 2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auInvoke.hpp
File: auTemplateMeta.hpp
Date: 2024-11-30
Date: 2024-03-01
Author: Reece
***/
#pragma once
#if !defined(AU_LANG_CPP_14_) && defined(AURORA_COMPILER_MSVC)
#define AuResultOf std::result_of
#define AuResultOf_mt(...) typename AuResultOf<__VA__ARGS__>::type
#elif !defined(AU_LANG_CPP_14)
template <class F, class... Args>
AUROXTL_CONSTEXPR AuResultOf_t<F, Args...> AuInvoke(F &&f, Args&&... args)
{
if AUROXTL_CONSTEXPR (AuIsMemberPointer_v<__audetail::remove_cvref_t<F>>)
{
return __audetail::invoke_memptr(f, AuForward<Args>(args)...);
}
else
{
return AuForward<F>(f)(AuForward<Args>(args)...);
}
}
#else
template <class F, class... Args>
AuResultOf_t<F, Args...> AuInvoke(F &&f, Args&&... args)
{
return AuForward<F>(std::invoke(f, AuForward<Args>(args)...));
}
#endif