diff --git a/include/zll/meta/traits/is_function.hpp b/include/zll/meta/traits/is_function.hpp new file mode 100644 index 0000000..a848e97 --- /dev/null +++ b/include/zll/meta/traits/is_function.hpp @@ -0,0 +1,26 @@ +#ifndef ZLL_META_TRAITS_ISFUNCTION_HPP +#define ZLL_META_TRAITS_ISFUNCTION_HPP + +#include "zll/meta/integral_constant.hpp" +#include "zll/meta/traits/is_const.hpp" +#include "zll/meta/traits/is_reference.hpp" + +namespace zll { +namespace meta { + +namespace detail { + +template +struct is_function_helper { + static const bool value = !(zll::meta::is_const::value) && !(zll::meta::is_reference::value); +}; + +} // namespace detail + +template +struct is_function : zll::meta::bool_constant::value> {}; + +} // namespace meta +} // namespace zll + +#endif // ZLL_META_TRAITS_ISFUNCTION_HPP diff --git a/tests/unit_tests/meson.build b/tests/unit_tests/meson.build index f791eba..f397a04 100644 --- a/tests/unit_tests/meson.build +++ b/tests/unit_tests/meson.build @@ -12,6 +12,7 @@ unit_tests_srcs = [ 'meta/traits/is_const_tests.cpp', 'meta/traits/is_enum_tests.cpp', 'meta/traits/is_floating_point_tests.cpp', + 'meta/traits/is_function_tests.cpp', 'meta/traits/is_integral_tests.cpp', 'meta/traits/is_member_pointer_tests.cpp', 'meta/traits/is_object_tests.cpp', diff --git a/tests/unit_tests/meta/traits/is_function_tests.cpp b/tests/unit_tests/meta/traits/is_function_tests.cpp new file mode 100644 index 0000000..3af5fa4 --- /dev/null +++ b/tests/unit_tests/meta/traits/is_function_tests.cpp @@ -0,0 +1,31 @@ +#include +#include + +#include + +struct test_struct { + int fun() const; +}; + +int test_function(); + +template +struct test_trait {}; +template +struct test_trait { + typedef U member_type; +}; + +UTEST(meta_traits_is_function, is_function) { + ASSERT_TRUE((zll::meta::is_function::value)); + ASSERT_TRUE((zll::meta::is_function::value)); + + typedef test_trait::member_type fun_type; + ASSERT_TRUE((zll::meta::is_function::value)); +} + +UTEST(meta_traits_is_function, is_not_function) { + ASSERT_FALSE((zll::meta::is_function::value)); + ASSERT_FALSE((zll::meta::is_function::value)); +} +