How to C++11 static_assert for type constraint? -
how can make static_assert
specific type constraint?
currently want make template unsigned int
type, not signed int
type. or, integral type, or specific type names. static_assert(sizeof(int))
offers size based assertion, , don't know how perform checks.
i using clang libc++
in xcode 4.6.2. here's current compiler information on command-line.
apple llvm version 4.2 (clang-425.0.28) (based on llvm 3.2svn) target: x86_64-apple-darwin12.3.0 thread model: posix
that's not static_assert
for, can this:
template<typename t> struct type { static_assert(std::is_same<t, unsigned int>::value, "bad t"); };
or, if want t
unsigned integral type of sort (not unsigned int
):
template<typename t> struct type { static_assert(std::is_unsigned<t>::value, "bad t"); };
Comments
Post a Comment