Question: I'm trying to trigger a compile time error if the user of my library tries to instantiate a template with a type that is not appropriate. I've implemented:

```
template <typename T>
struct good_type { enum { value = false }; };

template <>
struct good_type<string> { enum { value = true }; };

template <>
struct good_type<int64_t> { enum { value = true }; };

template <typename T>
struct X
{
  BOOST_STATIC_ASSERT(good_type<T>::value);
};

int main(int argc, char** argv)
{
  X<string> x1; 
  X<int64_t> x2;
  X<float> x3; 
  return 0;
}

```

which works, but the message I get from gcc is a bit surprising: 

```
error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' 

```

Should I be using a different Boost macro? Is there a better way to do this?

Thanks!

Answer: 
How about this :

```
#include <string>

template <typename T>
struct good_type;

template <>
struct good_type< std::string > {};

template <>
struct good_type< int > {};

template < typename T >
struct X
{
  good_type< T > someVar;
};

int main(int argc, char** argv)
{
  X< std::string > x1;
  X< int > x2;
  X<float> x3;
}

```

produces :

```
main.cpp: In instantiation of ‘X<float>’:
main.cpp:22:12:   instantiated from here
main.cpp:15:18: error: ‘X<T>::someVar’ has incomplete type
main.cpp:4:8: error: declaration of ‘struct good_type<float>’

```
`BOOST_MPL_ASSERT` produces better messages: <http://ideone.com/BR0GJ>

```
prog.cpp: In instantiation of ‘X<float>’:
prog.cpp:24:   instantiated from here
prog.cpp:17: error: no matching function for call to 
  ‘assertion_failed(mpl_::failed************ good_type<float>::************)’
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:22: warning: unused variable ‘x1’
prog.cpp:23: warning: unused variable ‘x2’
prog.cpp:24: warning: unused variable ‘x3’

```