When writing generic code, I often want a simple type T for which sizeof(T) > 1 is guaranteed.
For example:
template <typename T>
char test_foo(...);
template <typename T,
typename = std::enable_if_t<std::is_member_function_pointer_v<decltype(&T::foo)>>>
??? test_foo(int);
template <typename T>
struct has_foo : std::bool_constant<sizeof(test_foo<T>(0))!=1> {};
I have a few options, but none is ideal:
long long: does not work, see herestruct SizeNot1 { char dummy[2]; };: have to define it ahead, a little bit annoyingchar (&test_foo())[2];: too uglystd::array<char, 2>: is its size guaranteed?
Any ideas?