AuROXTL/Include/auROXTL/auTemplateMetaIsFunction.hpp

181 lines
5.7 KiB
C++
Raw Normal View History

2022-04-01 04:06:53 +00:00
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auTemplateMetaIsFunction.hpp
Date: 2022-3-28
Author: Reece
Copy/pasted: https://en.cppreference.com/w/cpp/types/AuIsFunction
***/
#pragma once
2022-04-04 06:55:47 +00:00
#if defined(AURORA_COMPILER_CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wambiguous-ellipsis"
#endif
2022-04-01 04:06:53 +00:00
// primary
template <class>
struct AuIsFunction : AuFalseType { };
// specialization for regular functions
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...)> : AuTrueType {};
// specialization for variadic functions such as std::printf
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......)> : AuTrueType {};
// specialization for function types that have cv-qualifiers
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile> : AuTrueType {};
// specialization for function types that have ref-qualifiers
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile &> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile &&> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile &&> : AuTrueType {};
// specializations for noexcept versions of all the above (C++17 and later)
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile & noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) volatile && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args...) const volatile && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) volatile && noexcept> : AuTrueType {};
template <class Ret, class... Args>
struct AuIsFunction<Ret(Args......) const volatile && noexcept> : AuTrueType {};
template <class T>
2022-04-04 06:55:47 +00:00
inline constexpr bool AuIsFunction_v = AuIsFunction<T>::value;
#if defined(AURORA_COMPILER_CLANG)
#pragma clang diagnostic pop
#endif