3 #ifndef INCLUDE_NN_NLIB_CONFIG_H_ 4 #define INCLUDE_NN_NLIB_CONFIG_H_ 15 #if defined(n_EXPORTS) 16 #undef NLIB_VIS_PUBLIC 17 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 18 #elif defined(nx_misc_EXPORTS) 19 #undef NLIB_VIS_PUBLIC 20 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 24 #ifndef NLIB_NAMESPACE_BEGIN 25 #define NLIB_NAMESPACE_BEGIN namespace nn { namespace nlib { 28 #ifndef NLIB_NAMESPACE_END 29 #define NLIB_NAMESPACE_END }} 33 #define NLIB_NS ::nn::nlib 41 # include "nn/nlib/Config_cafe.h" 42 #elif defined(NN_PLATFORM_CTR) 43 # include "nn/nlib/Config_ctr.h" 45 # include "nn/nlib/Config_nx.h" 46 #elif defined(_MSC_VER) 47 # include "nn/nlib/Config_win32.h" 48 #elif defined(__CYGWIN__) 49 # include "nn/nlib/Config_cygwin.h" 50 #elif defined(__linux__) 51 # include "nn/nlib/Config_linux.h" 52 #elif defined(__FreeBSD__) 53 # include "nn/nlib/Config_freebsd.h" 54 #elif defined(__APPLE__) && defined(__MACH__) 55 # include "nn/nlib/Config_osx.h" 58 #ifdef NLIB_CXX11_STDLIB_ATOMIC 60 # undef NLIB_MEMORY_ORDER_RELEASE 61 # undef NLIB_MEMORY_ORDER_ACQUIRE 62 # undef NLIB_MEMORY_ORDER_ACQ_REL 64 # define NLIB_MEMORY_ORDER_RELEASE ::std::atomic_thread_fence(::std::memory_order_release) 65 # define NLIB_MEMORY_ORDER_ACQUIRE ::std::atomic_thread_fence(::std::memory_order_acquire) 66 # define NLIB_MEMORY_ORDER_ACQ_REL ::std::atomic_thread_fence(::std::memory_order_acq_rel) 69 #ifdef NLIB_CXX11_RVALUE_REFERENCES 71 # define NLIB_FWD(T, v) std::forward<T>(v) 72 # define NLIB_MOVE(x) std::move(x) 75 # define NLIB_FWD(T, v) (v) 76 # define NLIB_MOVE(x) (x) 79 #ifdef NLIB_CXX11_CONSTEXPR 80 # define NLIB_CEXPR constexpr 86 #define NLIB_NOEXCEPT noexcept 90 # define NLIB_NOEXCEPT 91 #elif defined(__INTELLISENSE__) 93 # define NLIB_NOEXCEPT 96 struct nlib_unwind_exception {};
97 #ifndef NLIB_RETHROW_UNWIND 98 # define NLIB_RETHROW_UNWIND catch (nlib_unwind_exception&) 101 #ifndef NLIB_ASSERT_NOERR 102 # define NLIB_ASSERT_NOERR(e) NLIB_ASSERT((e) == 0) 105 #ifdef NLIB_EXCEPTION_ENABLED 106 # define NLIB_TRY try 107 # define NLIB_CATCH(x) catch(x) 108 # define NLIB_THROW throw 110 # define NLIB_TRY if (true) 111 # define NLIB_CATCH(x) if (false) 115 #ifndef NLIB_STATIC_ASSERT 116 #ifndef NLIB_CXX11_STATIC_ASSERTIONS 120 struct STATIC_ASSERTION_FAILURE;
122 struct STATIC_ASSERTION_FAILURE<true> {};
124 struct static_assert_test {};
128 #define NLIB_ASSERT_H_STRING_JOIN_(X, Y) NLIB_ASSERT_H_STRING_JOIN1_(X, Y) 129 #define NLIB_ASSERT_H_STRING_JOIN1_(X, Y) X##Y 131 #define NLIB_STATIC_ASSERT(exp) \ 132 typedef ::nlib_ns::detail::static_assert_test< \ 133 sizeof(::nlib_ns::detail::STATIC_ASSERTION_FAILURE<(exp) != 0>)> \ 134 NLIB_ASSERT_H_STRING_JOIN_(nn_static_assert_typedef_, __LINE__) 136 # define NLIB_STATIC_ASSERT(exp) static_assert((exp), "NLIB_STATIC_ASSERT error: " #exp) 140 #ifndef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS 141 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 142 TypeName(const TypeName&); \ 143 void operator=(const TypeName&) 145 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 146 TypeName(const TypeName&) = delete; \ 147 void operator=(const TypeName&) = delete 150 #ifndef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS 151 #define NLIB_SAFE_BOOL(class_name, exp) \ 153 typedef void (class_name::*bool_type)() const; \ 154 void this_type_does_not_support_comparisons() const NLIB_NOEXCEPT {} \ 156 operator bool_type() const NLIB_NOEXCEPT { \ 157 return (exp) ? &class_name::this_type_does_not_support_comparisons : 0; \ 160 #define NLIB_SAFE_BOOL(class_name, exp) \ 162 explicit NLIB_ALWAYS_INLINE operator bool() const NLIB_NOEXCEPT { return (exp); } 166 #if defined(WCHAR_MIN) && defined(WCHAR_MAX) 167 # if WCHAR_MAX <= 0xFFFF 168 # define NLIB_WCHAR_SIZE (2) 171 # define NLIB_WCHAR_SIZE (4) 175 # error WCHAR_MIN, WCHAR_MAX not defined 178 #ifndef NLIB_CXX11_NULL_POINTER_CONSTANT 183 operator T*()
const {
186 template <
class C,
class T>
187 operator T C::*()
const {
192 void operator&()
const;
196 const nullptr_t
nullptr = {};
202 typedef std::nullptr_t nullptr_t;
206 #ifndef NLIB_CXX11_EXPLICIT_VIRTUAL_OVERRIDES 207 # define NLIB_OVERRIDE 210 # define NLIB_OVERRIDE override 211 # define NLIB_FINAL final 214 #ifdef NLIB_CXX11_ALIGNMENT_SUPPORT 221 # define NLIB_ALIGNAS(x) alignas(x) 222 # define NLIB_ALIGNOF(tp) alignof(tp) 225 #ifdef NLIB_CXX11_RVALUE_REFERENCES 234 #define NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 236 tp& assign(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT { \ 242 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) \ 243 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 245 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : mem1() \ 250 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) \ 251 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 253 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : mem1(), \ 259 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) \ 260 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 262 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 269 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) \ 270 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 272 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 280 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) \ 281 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 283 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 292 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 293 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 295 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 305 #ifdef NLIB_CXX11_RVALUE_REFERENCES 306 #define NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) \ 308 tp& operator=(tp&& rhs) NLIB_NOEXCEPT { \ 309 tp tmp(std::move(rhs)); \ 314 #ifdef NLIB_CXX11_DELEGATING_CONSTRUCTORS 315 #define NLIB_MOVE_MEMBER_HELPER_(tp) \ 316 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 317 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) \ 319 tp(tp&& rhs) NLIB_NOEXCEPT : tp() { this->swap(rhs); } \ 321 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : tp() { this->swap(rhs); } // NOLINT 323 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) NLIB_MOVE_MEMBER_HELPER_(tp) 324 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) NLIB_MOVE_MEMBER_HELPER_(tp) 325 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) NLIB_MOVE_MEMBER_HELPER_(tp) 326 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) NLIB_MOVE_MEMBER_HELPER_(tp) 327 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) NLIB_MOVE_MEMBER_HELPER_(tp) 328 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 329 NLIB_MOVE_MEMBER_HELPER_(tp) 332 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) \ 334 tp(tp&& rhs) NLIB_NOEXCEPT : mem1() { this->swap(rhs); } \ 335 NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) \ 336 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 338 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) \ 340 tp(tp&& rhs) : mem1(), mem2() { this->swap(rhs); } \ 341 NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) \ 342 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 344 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) \ 346 tp(tp&& rhs) : mem1(), mem2(), mem3() { this->swap(rhs); } \ 347 NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) \ 348 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 350 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) \ 352 tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4() { this->swap(rhs); } \ 353 NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) \ 354 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 356 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) \ 358 tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4(), mem5() { this->swap(rhs); } \ 359 NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) \ 360 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 362 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 364 tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4(), mem5(), mem6() { this->swap(rhs); } \ 365 NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 366 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 370 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) 372 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) 374 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) \ 375 NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) 377 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) \ 378 NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) 380 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) \ 381 NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) 383 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 384 NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) 388 #ifndef NLIB_MEMCHECKER 389 # define NLIB_MEMCHECKER NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT 390 # define NLIB_MEMCHECKER_START NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT 391 # define NLIB_MEMCHECKER_CHECK true 396 #ifndef NLIB_NOEMPTYFILE 397 # define NLIB_NOEMPTYFILE() 400 #ifdef NLIB_SOCKET_ENABLED 404 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 50) 406 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER) 410 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 75) 412 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 25) 415 # elif defined(__clang__) 417 # define NLIB_SOCKPORT_SAMPLE (18174) 419 # define NLIB_SOCKPORT_SAMPLE (18074) 423 # define NLIB_SOCKPORT_SAMPLE (17874) 425 # define NLIB_SOCKPORT_SAMPLE (17974) 438 #if !defined(NLIB_CIBUILD) && defined(NDEBUG) 439 # define NLIB_TESTLOOPCOUNT(x) (x) 441 # define NLIB_TESTLOOPCOUNT(x) (1) 444 #ifndef NLIB_OVERRIDE_NEW 445 #define NLIB_OVERRIDE_NEW \ 446 static void* operator new(size_t size); \ 447 static void operator delete(void* ptr); \ 448 static void* operator new(size_t size, void* ptr) NLIB_NOEXCEPT; \ 449 static void operator delete(void* mem, void* ptr) NLIB_NOEXCEPT; \ 450 static void* operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT; \ 451 static void operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT 454 #ifndef NLIB_OVERRIDE_NEW_LIBNEW_CPP 455 #define NLIB_OVERRIDE_NEW_LIBNEW_CPP(type) \ 456 void* type::operator new(size_t size) { return ::operator new(size); } \ 457 void type::operator delete(void* ptr) { ::operator delete(ptr); } \ 458 void* type::operator new(size_t size, void* ptr) NLIB_NOEXCEPT { \ 459 return ::operator new(size, ptr); \ 461 void type::operator delete(void* mem, void* ptr) NLIB_NOEXCEPT { \ 462 ::operator delete(mem, ptr); \ 464 void* type::operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT { \ 465 return ::operator new(size, nt); \ 467 void type::operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT { \ 469 ::operator delete(mem); \ 487 bool operator!()
const;
493 return lhs.operator
errno_t() == rhs;
497 return rhs.operator
errno_t() == lhs;
501 return lhs.operator
errno_t() != rhs;
505 return rhs.operator
errno_t() != lhs;
514 const char& operator[](
size_t idx)
const NLIB_NOEXCEPT {
return str_[idx]; }
525 operator const char*()
const NLIB_NOEXCEPT {
return &str_[0]; }
526 const char& operator[](
size_t idx)
const NLIB_NOEXCEPT {
return str_[idx]; }
527 char& operator[](
size_t idx)
NLIB_NOEXCEPT {
return str_[idx]; }
534 #ifdef NLIB_CXX11_NEW_CHARACTER_TYPES 590 size_t* __restrict to_count,
size_t* __restrict from_count,
591 char* __restrict to,
size_t to_size,
592 const nlib_utf16_t* __restrict from,
size_t from_size)
595 size_t* __restrict to_count,
size_t* __restrict from_count,
596 nlib_utf16_t* __restrict to,
size_t to_size,
597 const char* __restrict from,
size_t from_size)
600 size_t* __restrict to_count,
size_t* __restrict from_count,
601 char* __restrict to,
size_t to_size,
602 const nlib_utf32_t* __restrict from,
size_t from_size)
605 size_t* __restrict to_count,
size_t* __restrict from_count,
606 nlib_utf32_t* __restrict to,
size_t to_size,
607 const char* __restrict from,
size_t from_size)
610 NLIB_VIS_PUBLIC_ALT
size_t nlib_utf16len_(
612 NLIB_VIS_PUBLIC_ALT
size_t nlib_utf16nlen_(
625 const nlib_utf16_t* str) NLIB_NOEXCEPT {
626 return nlib_utf16len_(reinterpret_cast<const uint16_t*>(str));
629 const nlib_utf16_t* str,
630 size_t maxsize) NLIB_NOEXCEPT {
631 return nlib_utf16nlen_(reinterpret_cast<const uint16_t*>(str), maxsize);
636 const nlib_utf16_t* s2) NLIB_NOEXCEPT {
637 return nlib_utf16cpy_(reinterpret_cast<uint16_t*>(s1), s1max,
638 reinterpret_cast<const uint16_t*>(s2));
643 const nlib_utf16_t* s2,
644 size_t n) NLIB_NOEXCEPT {
645 return nlib_utf16ncpy_(reinterpret_cast<uint16_t*>(s1), s1max,
646 reinterpret_cast<const uint16_t*>(s2), n);
649 NLIB_VIS_PUBLIC_ALT
size_t nlib_utf32len_(
651 NLIB_VIS_PUBLIC_ALT
size_t nlib_utf32nlen_(
664 const nlib_utf32_t* str) NLIB_NOEXCEPT {
665 return nlib_utf32len_(reinterpret_cast<const uint32_t*>(str));
668 const nlib_utf32_t* str,
669 size_t maxsize) NLIB_NOEXCEPT {
670 return nlib_utf32nlen_(reinterpret_cast<const uint32_t*>(str), maxsize);
675 const nlib_utf32_t* s2) NLIB_NOEXCEPT {
676 return nlib_utf32cpy_(reinterpret_cast<uint32_t*>(s1), s1max,
677 reinterpret_cast<const uint32_t*>(s2));
682 const nlib_utf32_t* s2,
683 size_t n) NLIB_NOEXCEPT {
684 return nlib_utf32ncpy_(reinterpret_cast<uint32_t*>(s1), s1max,
685 reinterpret_cast<const uint32_t*>(s2), n);
695 const nlib_utf16_t* str) NLIB_NOEXCEPT {
696 return nlib_utf16cplen_ex_(count, NULL, reinterpret_cast<const uint16_t*>(str));
701 const nlib_utf16_t* str) NLIB_NOEXCEPT {
702 return nlib_utf16cplen_ex_(count, len, reinterpret_cast<const uint16_t*>(str));
714 _Printf_format_string_
const char* fmt,
723 _Printf_format_string_
const char* fmt,
736 _Printf_format_string_
const wchar_t* fmt,
745 _Printf_format_string_
const wchar_t* fmt,
758 _Printf_format_string_
const char* fmt,
760 return nlib_vsnprintf_fallback(count, buf, N, fmt, args);
767 _Printf_format_string_
const char* fmt,
771 errno_t e = nlib_vsnprintf_fallback(count, buf, N, fmt, args);
780 _Printf_format_string_
const wchar_t* fmt,
782 return nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
789 _Printf_format_string_
const wchar_t* fmt,
793 errno_t e = nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
872 size_t* to_count,
size_t* from_count,
879 size_t* to_count,
size_t* from_count,
880 nlib_utf16_t (&to)[N],
886 size_t* to_count,
size_t* from_count,
893 size_t* to_count,
size_t* from_count,
894 nlib_utf32_t (&to)[N],
900 size_t* to_count,
size_t* from_count,
907 size_t* to_count,
size_t* from_count,
913 #if !defined(NN_PLATFORM_CTR) && !defined(CAFE) 923 #ifdef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS 924 return !obj.operator bool();
929 #ifdef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS 937 #endif // __cplusplus 946 #if defined(_MSC_VER) 947 #if defined(n_EXPORTS) 948 #undef NLIB_VIS_PUBLIC 949 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 950 #elif defined(nx_misc_EXPORTS) 951 #undef NLIB_VIS_PUBLIC 952 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 956 #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を利用します。