Skip to content

Commit

Permalink
is_complete.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
i-saint committed Jul 24, 2013
1 parent 82b6142 commit e2bad04
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions is_complete.cpp
@@ -0,0 +1,23 @@
#include <cstdio>

template<class T>
struct is_complete
{
// VisualC++ only
// other approach: http://stackoverflow.com/questions/1625105/how-to-write-is-complete-template/1625360
static const bool value = __alignof(T)!=0;
};

class Hoge;
class Hage {};


int main()
{
printf("is_complete<Hoge>: %d\n", is_complete<Hoge>::value);
printf("is_complete<Hage>: %d\n", is_complete<Hage>::value);
}

// $ cl incomplete_type.cpp && ./incomplete_type
// is_complete<Hoge>: 0
// is_complete<Hage>: 1

0 comments on commit e2bad04

Please sign in to comment.