1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
/* Copyright 2016 - 2016, The libsigc++ Development Team
* Assigned to public domain. Use as you wish without restriction.
*/
#include <cstdlib>
#include <sigc++/member_method_trait.h>
#include <type_traits>
namespace
{
class Something
{
public:
void some_func(int) {}
void some_const_func(int) const {}
void some_volatile_func(int) volatile {}
void some_const_volatile_func(int) const volatile {}
int some_int_func() { return 1; }
bool some_bool_func() { return true; }
};
} // end anonymous namespace
void
test_member_method_is_const()
{
static_assert(!sigc::internal::member_method_is_const<decltype(&Something::some_func)>::value,
"member_method_is_const failed to identify a non-const member method.");
static_assert(
!sigc::internal::member_method_is_const<decltype(&Something::some_volatile_func)>::value,
"member_method_is_const failed to identify a non-const member method.");
static_assert(
sigc::internal::member_method_is_const<decltype(&Something::some_const_func)>::value,
"member_method_is_const failed to identify a const member method.");
static_assert(
sigc::internal::member_method_is_const<decltype(&Something::some_const_volatile_func)>::value,
"member_method_is_const failed to identify a const member method.");
}
void
test_member_method_is_volatile()
{
static_assert(!sigc::internal::member_method_is_volatile<decltype(&Something::some_func)>::value,
"member_method_is_const failed to identify a non-volatile member method.");
static_assert(
!sigc::internal::member_method_is_volatile<decltype(&Something::some_const_func)>::value,
"member_method_is_const failed to identify a non-volatile member method.");
static_assert(
sigc::internal::member_method_is_volatile<decltype(&Something::some_volatile_func)>::value,
"member_method_is_const failed to identify a volatile member method.");
static_assert(sigc::internal::member_method_is_volatile<
decltype(&Something::some_const_volatile_func)>::value,
"member_method_is_const failed to identify a volatile member method.");
}
void
test_member_method_class_type()
{
static_assert(
std::is_same<sigc::internal::member_method_class<decltype(&Something::some_func)>::type,
Something>::value,
"member_method_class_type failed to identify the class type.");
}
void
test_member_method_result_type()
{
static_assert(
std::is_same<sigc::internal::member_method_result<decltype(&Something::some_int_func)>::type,
int>::value,
"member_method_result_type failed to identify the result type.");
static_assert(
std::is_same<sigc::internal::member_method_result<decltype(&Something::some_bool_func)>::type,
bool>::value,
"member_method_result_type failed to identify the result type.");
}
int
main()
{
test_member_method_is_const();
test_member_method_is_volatile();
test_member_method_class_type();
test_member_method_result_type();
return EXIT_SUCCESS;
}
|