HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SYS_StaticAssert.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: SYS_StaticAssert.h ( SYS Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __SYS_StaticAssert__
12 #define __SYS_StaticAssert__
13 
14 /// A macro to trigger assertions at compile-time. Comes in two flavor, one
15 /// which simply shows the expression that failed, another one that allows
16 /// a custom message to be supplied.
17 
18 #if (__cplusplus >= 201103L) || (_MSC_VER >= 1700)
19 // C++11 has native static_assert support. For C++03 and prior, use Boost's
20 // version.
21 # define SYS_STATIC_ASSERT(expr) static_assert(expr, #expr)
22 # define SYS_STATIC_ASSERT_MSG(expr, msg) static_assert(expr, msg)
23 #else
24 # include <hboost/static_assert.hpp>
25 # define SYS_STATIC_ASSERT(expr) HBOOST_STATIC_ASSERT(expr)
26 # define SYS_STATIC_ASSERT_MSG(expr, msg) HBOOST_STATIC_ASSERT_MSG(expr, msg)
27 #endif
28 
29 /// Use this macro to trigger a compilation error on deliberately unimplemented
30 /// template functions. Pass in one of the template arguments, to make this
31 /// type-dependent.
32 #define SYS_UNIMPLEMENTED_TEMPLATE(T) \
33  SYS_STATIC_ASSERT_MSG(sizeof(T) == 0, "Unimplemented template function.")
34 
35 #endif // __SYS_StaticAssert__