#include #include #include /////////////////////////////////////////////////////////////////////////////// template constexpr bool returns_int (FuncT) { return std::is_same_v< int, typename func_traits::return_type >; } /////////////////////////////////////////////////////////////////////////////// template > struct has_return_type : std::false_type {}; //----------------------------------------------------------------------------- template struct has_return_type< T, std::void_t::return_type> > : std::true_type {}; /////////////////////////////////////////////////////////////////////////////// extern int plain (char, float) { return 0; } extern int with_noexcept (char, float) noexcept { return 0; } struct foo { int bar (double, char) const { return 0; } int with_noexcept (double, char) noexcept { return 0; } }; /////////////////////////////////////////////////////////////////////////////// int main (void) { cruft::TAP::logger tap; tap.expect (returns_int ( plain), "free-function by-reference"); tap.expect (returns_int (&plain), "free-function by-pointer"); tap.expect (returns_int ( with_noexcept), "free-function with noexcept by-reference"); tap.expect (returns_int (&with_noexcept), "free-function with noexcept by-pointer"); tap.expect (returns_int (&foo::bar), "member-function by reference"); tap.expect (returns_int (&foo::with_noexcept), "member-function with noexcept by reference"); using all_t = void (*const &)(void *, unsigned int, unsigned int, void **) noexcept; tap.expect (std::is_same_v::return_type>, "complex function type"); tap.expect (!has_return_type::value, "integer is not applicable to func_traits"); tap.expect (is_contiguous_v>, "vector is contiguous"); tap.expect (is_contiguous_v>, "array is contiguous"); tap.expect (!is_contiguous_v>, "list is not contiguous"); tap.expect ( cruft::is_same_basic_type_v, "float-double same_basic_type"); tap.expect (!cruft::is_same_basic_type_v, "float-int same_basic_type"); return tap.status (); }