16 #ifndef INCLUDE_NN_NLIB_CONFIG_H_ 17 #define INCLUDE_NN_NLIB_CONFIG_H_ 28 #if defined(n_EXPORTS) 29 #undef NLIB_VIS_PUBLIC 30 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 31 #elif defined(nx_misc_EXPORTS) 32 #undef NLIB_VIS_PUBLIC 33 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 37 #ifndef NLIB_NAMESPACE_BEGIN 38 #define NLIB_NAMESPACE_BEGIN namespace nn { namespace nlib { 41 #ifndef NLIB_NAMESPACE_END 42 #define NLIB_NAMESPACE_END }} 46 #define NLIB_NS ::nn::nlib 54 # include "nn/nlib/Config_cafe.h" 55 #elif defined(NN_PLATFORM_CTR) 56 # include "nn/nlib/Config_ctr.h" 58 # include "nn/nlib/Config_nx.h" 59 #elif defined(_MSC_VER) 60 # include "nn/nlib/Config_win32.h" 61 #elif defined(__CYGWIN__) 62 # include "nn/nlib/Config_cygwin.h" 63 #elif defined(__linux__) 64 # include "nn/nlib/Config_linux.h" 65 #elif defined(__FreeBSD__) 66 # include "nn/nlib/Config_freebsd.h" 67 #elif defined(__APPLE__) && defined(__MACH__) 68 # include "nn/nlib/Config_osx.h" 71 #ifdef NLIB_CXX11_STDLIB_ATOMIC 73 # undef NLIB_MEMORY_ORDER_RELEASE 74 # undef NLIB_MEMORY_ORDER_ACQUIRE 75 # undef NLIB_MEMORY_ORDER_ACQ_REL 77 # define NLIB_MEMORY_ORDER_RELEASE ::std::atomic_thread_fence(::std::memory_order_release) 78 # define NLIB_MEMORY_ORDER_ACQUIRE ::std::atomic_thread_fence(::std::memory_order_acquire) 79 # define NLIB_MEMORY_ORDER_ACQ_REL ::std::atomic_thread_fence(::std::memory_order_acq_rel) 82 #ifdef NLIB_CXX11_RVALUE_REFERENCES 84 # define NLIB_FWD(T, v) std::forward<T>(v) 85 # define NLIB_MOVE(x) std::move(x) 88 # define NLIB_FWD(T, v) (v) 89 # define NLIB_MOVE(x) (x) 92 #ifdef NLIB_CXX11_CONSTEXPR 93 # define NLIB_CEXPR constexpr 99 #define NLIB_NOEXCEPT noexcept 102 #ifndef NLIB_NOEXCEPT 103 # define NLIB_NOEXCEPT 104 #elif defined(__INTELLISENSE__) 105 # undef NLIB_NOEXCEPT 106 # define NLIB_NOEXCEPT 109 struct nlib_unwind_exception {};
110 #ifndef NLIB_RETHROW_UNWIND 111 # define NLIB_RETHROW_UNWIND catch (nlib_unwind_exception&) 114 #ifndef NLIB_ASSERT_NOERR 115 # define NLIB_ASSERT_NOERR(e) NLIB_ASSERT((e) == 0) 118 #ifdef NLIB_EXCEPTION_ENABLED 119 # define NLIB_TRY try 120 # define NLIB_CATCH(x) catch(x) 121 # define NLIB_THROW throw 123 # define NLIB_TRY if (true) 124 # define NLIB_CATCH(x) if (false) 128 #ifndef NLIB_STATIC_ASSERT 129 #ifndef NLIB_CXX11_STATIC_ASSERTIONS 133 struct STATIC_ASSERTION_FAILURE;
135 struct STATIC_ASSERTION_FAILURE<true> {};
137 struct static_assert_test {};
141 #define NLIB_ASSERT_H_STRING_JOIN_(X, Y) NLIB_ASSERT_H_STRING_JOIN1_(X, Y) 142 #define NLIB_ASSERT_H_STRING_JOIN1_(X, Y) X##Y 144 #define NLIB_STATIC_ASSERT(exp) \ 145 typedef ::nlib_ns::detail::static_assert_test< \ 146 sizeof(::nlib_ns::detail::STATIC_ASSERTION_FAILURE<(exp) != 0>)> \ 147 NLIB_ASSERT_H_STRING_JOIN_(nn_static_assert_typedef_, __LINE__) 149 # define NLIB_STATIC_ASSERT(exp) static_assert((exp), "NLIB_STATIC_ASSERT error: " #exp) 153 #ifndef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS 154 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 155 TypeName(const TypeName&); \ 156 void operator=(const TypeName&) 158 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 159 TypeName(const TypeName&) = delete; \ 160 void operator=(const TypeName&) = delete 163 #ifndef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS 164 #define NLIB_SAFE_BOOL(class_name, exp) \ 166 typedef void (class_name::*bool_type)() const; \ 167 void this_type_does_not_support_comparisons() const NLIB_NOEXCEPT {} \ 169 operator bool_type() const NLIB_NOEXCEPT { \ 170 return (exp) ? &class_name::this_type_does_not_support_comparisons : 0; \ 173 #define NLIB_SAFE_BOOL(class_name, exp) \ 175 explicit NLIB_ALWAYS_INLINE operator bool() const NLIB_NOEXCEPT { return (exp); } 179 #if defined(WCHAR_MIN) && defined(WCHAR_MAX) 180 # if WCHAR_MAX <= 0xFFFF 181 # define NLIB_WCHAR_SIZE (2) 184 # define NLIB_WCHAR_SIZE (4) 188 # error WCHAR_MIN, WCHAR_MAX not defined 191 #ifndef NLIB_CXX11_NULL_POINTER_CONSTANT 196 operator T*()
const {
199 template <
class C,
class T>
200 operator T C::*()
const {
205 void operator&()
const;
209 const nullptr_t
nullptr = {};
215 typedef std::nullptr_t nullptr_t;
219 #ifndef NLIB_CXX11_EXPLICIT_VIRTUAL_OVERRIDES 220 # define NLIB_OVERRIDE 223 # define NLIB_OVERRIDE override 224 # define NLIB_FINAL final 227 #ifdef NLIB_CXX11_ALIGNMENT_SUPPORT 234 # define NLIB_ALIGNAS(x) alignas(x) 235 # define NLIB_ALIGNOF(tp) alignof(tp) 238 #ifdef NLIB_CXX11_RVALUE_REFERENCES 247 #define NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 249 tp& assign(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT { \ 255 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) \ 256 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 258 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : mem1() \ 263 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) \ 264 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 266 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : mem1(), \ 272 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) \ 273 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 275 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 282 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) \ 283 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 285 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 293 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) \ 294 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 296 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 305 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 306 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 308 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 318 #ifdef NLIB_CXX11_RVALUE_REFERENCES 319 #define NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) \ 321 tp& operator=(tp&& rhs) NLIB_NOEXCEPT { \ 322 tp tmp(std::move(rhs)); \ 327 #ifdef NLIB_CXX11_DELEGATING_CONSTRUCTORS 328 #define NLIB_MOVE_MEMBER_HELPER_(tp) \ 329 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 330 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) \ 332 tp(tp&& rhs) NLIB_NOEXCEPT : tp() { this->swap(rhs); } \ 334 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : tp() { this->swap(rhs); } // NOLINT 336 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) NLIB_MOVE_MEMBER_HELPER_(tp) 337 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) NLIB_MOVE_MEMBER_HELPER_(tp) 338 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) NLIB_MOVE_MEMBER_HELPER_(tp) 339 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) NLIB_MOVE_MEMBER_HELPER_(tp) 340 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) NLIB_MOVE_MEMBER_HELPER_(tp) 341 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 342 NLIB_MOVE_MEMBER_HELPER_(tp) 345 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) \ 347 tp(tp&& rhs) NLIB_NOEXCEPT : mem1() { this->swap(rhs); } \ 348 NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) \ 349 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 351 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) \ 353 tp(tp&& rhs) : mem1(), mem2() { this->swap(rhs); } \ 354 NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) \ 355 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 357 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) \ 359 tp(tp&& rhs) : mem1(), mem2(), mem3() { this->swap(rhs); } \ 360 NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) \ 361 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 363 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) \ 365 tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4() { this->swap(rhs); } \ 366 NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) \ 367 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 369 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) \ 371 tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4(), mem5() { this->swap(rhs); } \ 372 NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) \ 373 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 375 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 377 tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4(), mem5(), mem6() { this->swap(rhs); } \ 378 NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 379 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 383 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) 385 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) 387 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) \ 388 NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) 390 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) \ 391 NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) 393 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) \ 394 NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) 396 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 397 NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) 401 #ifndef NLIB_MEMCHECKER 402 # define NLIB_MEMCHECKER NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT 403 # define NLIB_MEMCHECKER_START NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT 404 # define NLIB_MEMCHECKER_CHECK true 409 #ifndef NLIB_NOEMPTYFILE 410 # define NLIB_NOEMPTYFILE() 413 #ifdef NLIB_SOCKET_ENABLED 417 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 50) 419 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER) 423 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 75) 425 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 25) 428 # elif defined(__clang__) 430 # define NLIB_SOCKPORT_SAMPLE (18174) 432 # define NLIB_SOCKPORT_SAMPLE (18074) 436 # define NLIB_SOCKPORT_SAMPLE (17874) 438 # define NLIB_SOCKPORT_SAMPLE (17974) 451 #if !defined(NLIB_CIBUILD) && defined(NDEBUG) 452 # define NLIB_TESTLOOPCOUNT(x) (x) 454 # define NLIB_TESTLOOPCOUNT(x) (1) 457 #ifndef NLIB_OVERRIDE_NEW 458 #define NLIB_OVERRIDE_NEW \ 459 static void* operator new(size_t size); \ 460 static void operator delete(void* ptr); \ 461 static void* operator new(size_t size, void* ptr) NLIB_NOEXCEPT; \ 462 static void operator delete(void* mem, void* ptr) NLIB_NOEXCEPT; \ 463 static void* operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT; \ 464 static void operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT 467 #ifndef NLIB_OVERRIDE_NEW_LIBNEW_CPP 468 #define NLIB_OVERRIDE_NEW_LIBNEW_CPP(type) \ 469 void* type::operator new(size_t size) { return ::operator new(size); } \ 470 void type::operator delete(void* ptr) { ::operator delete(ptr); } \ 471 void* type::operator new(size_t size, void* ptr) NLIB_NOEXCEPT { \ 472 return ::operator new(size, ptr); \ 474 void type::operator delete(void* mem, void* ptr) NLIB_NOEXCEPT { \ 475 ::operator delete(mem, ptr); \ 477 void* type::operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT { \ 478 return ::operator new(size, nt); \ 480 void type::operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT { \ 482 ::operator delete(mem); \ 500 bool operator!()
const;
506 return lhs.operator
errno_t() == rhs;
510 return rhs.operator
errno_t() == lhs;
514 return lhs.operator
errno_t() != rhs;
518 return rhs.operator
errno_t() != lhs;
527 const char& operator[](
size_t idx)
const NLIB_NOEXCEPT {
return str_[idx]; }
538 operator const char*()
const NLIB_NOEXCEPT {
return &str_[0]; }
539 const char& operator[](
size_t idx)
const NLIB_NOEXCEPT {
return str_[idx]; }
540 char& operator[](
size_t idx)
NLIB_NOEXCEPT {
return str_[idx]; }
547 #ifdef NLIB_CXX11_NEW_CHARACTER_TYPES 603 size_t* __restrict to_count,
size_t* __restrict from_count,
604 char* __restrict to,
size_t to_size,
605 const nlib_utf16_t* __restrict from,
size_t from_size)
608 size_t* __restrict to_count,
size_t* __restrict from_count,
609 nlib_utf16_t* __restrict to,
size_t to_size,
610 const char* __restrict from,
size_t from_size)
613 size_t* __restrict to_count,
size_t* __restrict from_count,
614 char* __restrict to,
size_t to_size,
615 const nlib_utf32_t* __restrict from,
size_t from_size)
618 size_t* __restrict to_count,
size_t* __restrict from_count,
619 nlib_utf32_t* __restrict to,
size_t to_size,
620 const char* __restrict from,
size_t from_size)
623 NLIB_VIS_PUBLIC_ALT
size_t nlib_utf16len_(
625 NLIB_VIS_PUBLIC_ALT
size_t nlib_utf16nlen_(
638 const nlib_utf16_t* str) NLIB_NOEXCEPT {
639 return nlib_utf16len_(reinterpret_cast<const uint16_t*>(str));
642 const nlib_utf16_t* str,
643 size_t maxsize) NLIB_NOEXCEPT {
644 return nlib_utf16nlen_(reinterpret_cast<const uint16_t*>(str), maxsize);
649 const nlib_utf16_t* s2) NLIB_NOEXCEPT {
650 return nlib_utf16cpy_(reinterpret_cast<uint16_t*>(s1), s1max,
651 reinterpret_cast<const uint16_t*>(s2));
656 const nlib_utf16_t* s2,
657 size_t n) NLIB_NOEXCEPT {
658 return nlib_utf16ncpy_(reinterpret_cast<uint16_t*>(s1), s1max,
659 reinterpret_cast<const uint16_t*>(s2), n);
662 NLIB_VIS_PUBLIC_ALT
size_t nlib_utf32len_(
664 NLIB_VIS_PUBLIC_ALT
size_t nlib_utf32nlen_(
677 const nlib_utf32_t* str) NLIB_NOEXCEPT {
678 return nlib_utf32len_(reinterpret_cast<const uint32_t*>(str));
681 const nlib_utf32_t* str,
682 size_t maxsize) NLIB_NOEXCEPT {
683 return nlib_utf32nlen_(reinterpret_cast<const uint32_t*>(str), maxsize);
688 const nlib_utf32_t* s2) NLIB_NOEXCEPT {
689 return nlib_utf32cpy_(reinterpret_cast<uint32_t*>(s1), s1max,
690 reinterpret_cast<const uint32_t*>(s2));
695 const nlib_utf32_t* s2,
696 size_t n) NLIB_NOEXCEPT {
697 return nlib_utf32ncpy_(reinterpret_cast<uint32_t*>(s1), s1max,
698 reinterpret_cast<const uint32_t*>(s2), n);
708 const nlib_utf16_t* str) NLIB_NOEXCEPT {
709 return nlib_utf16cplen_ex_(count, NULL, reinterpret_cast<const uint16_t*>(str));
714 const nlib_utf16_t* str) NLIB_NOEXCEPT {
715 return nlib_utf16cplen_ex_(count, len, reinterpret_cast<const uint16_t*>(str));
727 _Printf_format_string_
const char* fmt,
736 _Printf_format_string_
const char* fmt,
749 _Printf_format_string_
const wchar_t* fmt,
758 _Printf_format_string_
const wchar_t* fmt,
771 _Printf_format_string_
const char* fmt,
773 return nlib_vsnprintf_fallback(count, buf, N, fmt, args);
780 _Printf_format_string_
const char* fmt,
784 errno_t e = nlib_vsnprintf_fallback(count, buf, N, fmt, args);
793 _Printf_format_string_
const wchar_t* fmt,
795 return nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
802 _Printf_format_string_
const wchar_t* fmt,
806 errno_t e = nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
885 size_t* to_count,
size_t* from_count,
892 size_t* to_count,
size_t* from_count,
893 nlib_utf16_t (&to)[N],
899 size_t* to_count,
size_t* from_count,
906 size_t* to_count,
size_t* from_count,
907 nlib_utf32_t (&to)[N],
913 size_t* to_count,
size_t* from_count,
920 size_t* to_count,
size_t* from_count,
926 #if !defined(NN_PLATFORM_CTR) && !defined(CAFE) 936 #ifdef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS 937 return !obj.operator bool();
942 #ifdef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS 950 #endif // __cplusplus 959 #if defined(_MSC_VER) 960 #if defined(n_EXPORTS) 961 #undef NLIB_VIS_PUBLIC 962 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 963 #elif defined(nx_misc_EXPORTS) 964 #undef NLIB_VIS_PUBLIC 965 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 969 #endif // INCLUDE_NN_NLIB_CONFIG_H_
UTF-8を格納するcharの配列をラップするクラスです。Visual Studioのデバッガ上でのUTF-8の表示を改善します...
nlib_utf16_t utf16_t
UTF16の文字に対する型です。 nlib_utf16_tにtypedefされています。
bool operator==(const HeapHash &rhs, const HeapHash &lhs)
2つのサマリを比較して等価ならば、trueを返します。
bool operator!=(const HeapHash &rhs, const HeapHash &lhs)
2つのサマリを比較して等価でなければ、trueを返します。
空の構造体で、関数の引数をムーブすべきことを示すために利用されます。
errno_tをラップするクラスです。Visual Studioのデバッガ上での表示を改善します。
共通して使われることの多いストリーム関連のクラス群や各種コンテナ、及びガシェットクラスが実装されてい...
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
#define NLIB_CEXPR
利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
UTF-8を格納するconst char*をラップするクラスです。Visual Studioのデバッガ上でのUTF-8の表示を改善しま...
nlib_utf32_t utf32_t
UTF32の文字に対する型です。 nlib_utf32_tにtypedefされています。
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。
#define NLIB_STATIC_ASSERT(exp)
静的アサートが定義されます。利用可能であればstatic_assertを利用します。