In short:
How to write a test, that checks that my class is not copyable or copy-assignable, but is only moveable and move-assignable?
for example this std::is_nothrow_move_assignable
returns true
in compile-time.
for more checkers see https://en.cppreference.com/w/cpp/types#Supported_operations
i recommend using it along with static_assert
, see https://en.cppreference.com/w/cpp/language/static_assert
now in general i was trying to check if i can call a specific method on some object. this boils down to "assert if this code compiles" and there is a neat and short way to check it.
template using canCallPrintYesOn = decltype(::std::declval().printYes());
constexpr bool canCallPrintYesOn_MyType = std::experimental::is_detected::value;
static_assert(canCallPrintYesOn_MyType, "Should be able to call printYes(void) on this object");
if this fails, you get compile error with above string