How can I make compile time assertions without C++11
c++, templates
Solution
In your case
template <bool> struct assert;
template <> struct assert<true> {};
would have solved the problem:
assert<!is_pointer<char>::value>(); // valid
assert<is_pointer<char *>::value>(); // valid
assert<is_pointer<char>::value>(); // compilation error:
// use of incomplete class
Problem
In a job interview, I was asked to write a metafunction that determined whether a type was a pointer. This is what I presented: ``` template <typename T> struct is_pointer { static const bool value = false; } template <typename T> struct is_pointer<T *> { static const bool value = true; } ``` Then I was asked to write a meta-assert, that will fail during compile time if my `is_pointer` function is not doing the right thing. When I used `static_assert`, he explicitly told me that I may only use C++98 standard. How can I achieve this?