fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <class, int, class=void> struct is_complete : std::false_type {};
  5. template <class T, int i>
  6. struct is_complete<T, i, decltype(void(sizeof(T)))> : std::true_type {};
  7.  
  8. #define IS_COMPLETE(...) is_complete<__VA_ARGS__, __COUNTER__>::value
  9.  
  10. struct A;
  11. struct Foo {};
  12. int main() {
  13.  
  14. IS_COMPLETE(A);
  15. static_assert(IS_COMPLETE(Foo), "Type is not defined!");
  16.  
  17. return 0;
  18. }
  19.  
  20. struct A
  21. {
  22.  
  23. };
  24.  
  25.  
  26. void func()
  27. {
  28. static_assert(IS_COMPLETE(Foo), "Type is not defined!");
  29. }
Success #stdin #stdout 0s 3092KB
stdin
Standard input is empty
stdout
Standard output is empty