Consider the following case
typedef void (*foo)();
template<foo f>
struct bar {
static_assert(f!=nullptr,"f == null!");
};
void baz() {}
inline void bax() { }
bar<baz> ok;
bar<bax> bad; // error: non-constant condition for static assertion
Both baz
and bax
are accepted as template arguments.
It indicates that both are accepted as constants.
However, at static_assert
they appears to be different (at least in gcc 4.9) - bax
is not a constant anymore.
My assumption was that static_assert
and template evaluate constantness identically.
E.g. either error should be
- 'bax is not a valid template argument' or
static_assert
should not raise non-constant condition error.
Am I wrong?