static-assert/p4.cc - Static asserts abstracted in constexpr function. | Lecture 6 - slide 30 : 40 Program 3 |
// In p4.cc Does not compile on my laptop, float is not void or integral. #include <iostream> #include <string> #include <type_traits> template<class T> constexpr bool void_or_integral(){ return std::is_void<T>::value || std::is_integral<T>::value; } static_assert(void_or_integral<float>(), "Expected void or integral"); int main(){ }