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 100 #define NLIB_NOEXCEPT_FUNCPTR 103 #ifndef NLIB_NOEXCEPT 104 # define NLIB_NOEXCEPT 105 #elif defined(__INTELLISENSE__) 106 # undef NLIB_NOEXCEPT 107 # define NLIB_NOEXCEPT 110 #ifndef NLIB_NOEXCEPT_FUNCPTR 111 #define NLIB_NOEXCEPT_FUNCPTR 114 struct nlib_unwind_exception {};
115 #ifndef NLIB_RETHROW_UNWIND 116 # define NLIB_RETHROW_UNWIND catch (nlib_unwind_exception&) 119 #ifndef NLIB_ASSERT_NOERR 120 # define NLIB_ASSERT_NOERR(e) NLIB_ASSERT((e) == 0) 123 #ifdef NLIB_EXCEPTION_ENABLED 124 # define NLIB_TRY try 125 # define NLIB_CATCH(x) catch(x) 126 # define NLIB_THROW throw 128 # define NLIB_TRY if (true) 129 # define NLIB_CATCH(x) if (false) 133 #ifndef NLIB_STATIC_ASSERT 134 #ifndef NLIB_CXX11_STATIC_ASSERTIONS 138 struct STATIC_ASSERTION_FAILURE;
140 struct STATIC_ASSERTION_FAILURE<true> {};
142 struct static_assert_test {};
146 #define NLIB_ASSERT_H_STRING_JOIN_(X, Y) NLIB_ASSERT_H_STRING_JOIN1_(X, Y) 147 #define NLIB_ASSERT_H_STRING_JOIN1_(X, Y) X##Y 149 #define NLIB_STATIC_ASSERT(exp) \ 150 typedef ::nlib_ns::detail::static_assert_test< \ 151 sizeof(::nlib_ns::detail::STATIC_ASSERTION_FAILURE<(exp) != 0>)> \ 152 NLIB_ASSERT_H_STRING_JOIN_(nn_static_assert_typedef_, __LINE__) 154 # define NLIB_STATIC_ASSERT(exp) static_assert((exp), "NLIB_STATIC_ASSERT error: " #exp) 158 #ifndef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS 159 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 160 TypeName(const TypeName&); \ 161 void operator=(const TypeName&) 163 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 164 TypeName(const TypeName&) = delete; \ 165 void operator=(const TypeName&) = delete 168 #ifndef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS 169 #define NLIB_SAFE_BOOL(class_name, exp) \ 171 typedef void (class_name::*bool_type)() const; \ 172 void this_type_does_not_support_comparisons() const NLIB_NOEXCEPT {} \ 174 operator bool_type() const NLIB_NOEXCEPT { \ 175 return (exp) ? &class_name::this_type_does_not_support_comparisons : 0; \ 178 #define NLIB_SAFE_BOOL(class_name, exp) \ 180 explicit NLIB_ALWAYS_INLINE operator bool() const NLIB_NOEXCEPT { return (exp); } 184 #if defined(WCHAR_MIN) && defined(WCHAR_MAX) 185 # if WCHAR_MAX <= 0xFFFF 186 # define NLIB_WCHAR_SIZE (2) 189 # define NLIB_WCHAR_SIZE (4) 193 # error WCHAR_MIN, WCHAR_MAX not defined 196 #ifndef NLIB_CXX11_NULL_POINTER_CONSTANT 201 operator T*()
const {
204 template <
class C,
class T>
205 operator T C::*()
const {
210 void operator&()
const;
214 const nullptr_t
nullptr = {};
220 typedef std::nullptr_t nullptr_t;
224 #ifndef NLIB_CXX11_EXPLICIT_VIRTUAL_OVERRIDES 225 # define NLIB_OVERRIDE 228 # define NLIB_OVERRIDE override 229 # define NLIB_FINAL final 232 #ifdef NLIB_CXX11_ALIGNMENT_SUPPORT 239 # define NLIB_ALIGNAS(x) alignas(x) 240 # define NLIB_ALIGNOF(tp) alignof(tp) 243 #ifdef NLIB_CXX11_RVALUE_REFERENCES 252 #define NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 254 tp& assign(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT { \ 260 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) \ 261 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 263 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : mem1() \ 268 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) \ 269 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 271 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : mem1(), \ 277 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) \ 278 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 280 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 287 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) \ 288 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 290 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 298 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) \ 299 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 301 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 310 #define NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 311 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 313 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : \ 323 #ifdef NLIB_CXX11_RVALUE_REFERENCES 324 #define NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) \ 326 tp& operator=(tp&& rhs) NLIB_NOEXCEPT { \ 327 tp tmp(std::move(rhs)); \ 332 #ifdef NLIB_CXX11_DELEGATING_CONSTRUCTORS 333 #define NLIB_MOVE_MEMBER_HELPER_(tp) \ 334 NLIB_MOVE_MEMBER_HELPER_COMMON(tp) \ 335 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) \ 337 tp(tp&& rhs) NLIB_NOEXCEPT : tp() { this->swap(rhs); } \ 339 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : tp() { this->swap(rhs); } // NOLINT 341 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) NLIB_MOVE_MEMBER_HELPER_(tp) 342 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) NLIB_MOVE_MEMBER_HELPER_(tp) 343 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) NLIB_MOVE_MEMBER_HELPER_(tp) 344 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) NLIB_MOVE_MEMBER_HELPER_(tp) 345 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) NLIB_MOVE_MEMBER_HELPER_(tp) 346 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 347 NLIB_MOVE_MEMBER_HELPER_(tp) 350 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) \ 352 tp(tp&& rhs) NLIB_NOEXCEPT : mem1() { this->swap(rhs); } \ 353 NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) \ 354 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 356 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) \ 358 tp(tp&& rhs) : mem1(), mem2() { this->swap(rhs); } \ 359 NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) \ 360 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 362 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) \ 364 tp(tp&& rhs) : mem1(), mem2(), mem3() { this->swap(rhs); } \ 365 NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) \ 366 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 368 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) \ 370 tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4() { this->swap(rhs); } \ 371 NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) \ 372 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 374 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) \ 376 tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4(), mem5() { this->swap(rhs); } \ 377 NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) \ 378 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 380 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 382 tp(tp&& rhs) : mem1(), mem2(), mem3(), mem4(), mem5(), mem6() { this->swap(rhs); } \ 383 NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 384 NLIB_MOVE_MEMBER_HELPER_X_COMMON(tp) 388 #define NLIB_MOVE_MEMBER_HELPER_1(tp, mem1) NLIB_MOVE_MEMBER_HELPER_WITHTAG_1(tp, mem1) 390 #define NLIB_MOVE_MEMBER_HELPER_2(tp, mem1, mem2) NLIB_MOVE_MEMBER_HELPER_WITHTAG_2(tp, mem1, mem2) 392 #define NLIB_MOVE_MEMBER_HELPER_3(tp, mem1, mem2, mem3) \ 393 NLIB_MOVE_MEMBER_HELPER_WITHTAG_3(tp, mem1, mem2, mem3) 395 #define NLIB_MOVE_MEMBER_HELPER_4(tp, mem1, mem2, mem3, mem4) \ 396 NLIB_MOVE_MEMBER_HELPER_WITHTAG_4(tp, mem1, mem2, mem3, mem4) 398 #define NLIB_MOVE_MEMBER_HELPER_5(tp, mem1, mem2, mem3, mem4, mem5) \ 399 NLIB_MOVE_MEMBER_HELPER_WITHTAG_5(tp, mem1, mem2, mem3, mem4, mem5) 401 #define NLIB_MOVE_MEMBER_HELPER_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) \ 402 NLIB_MOVE_MEMBER_HELPER_WITHTAG_6(tp, mem1, mem2, mem3, mem4, mem5, mem6) 406 #ifndef NLIB_MEMCHECKER 407 # define NLIB_MEMCHECKER NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT 408 # define NLIB_MEMCHECKER_START NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT 409 # define NLIB_MEMCHECKER_CHECK true 414 #ifndef NLIB_NOEMPTYFILE 415 # define NLIB_NOEMPTYFILE() 418 #ifdef NLIB_SOCKET_ENABLED 422 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 50) 424 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER) 428 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 75) 430 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 25) 433 # elif defined(__clang__) 435 # define NLIB_SOCKPORT_SAMPLE (18174) 437 # define NLIB_SOCKPORT_SAMPLE (18074) 441 # define NLIB_SOCKPORT_SAMPLE (17874) 443 # define NLIB_SOCKPORT_SAMPLE (17974) 456 #if !defined(NLIB_CIBUILD) && defined(NDEBUG) 457 # define NLIB_TESTLOOPCOUNT(x) (x) 459 # define NLIB_TESTLOOPCOUNT(x) (1) 462 #ifndef NLIB_OVERRIDE_NEW 463 #define NLIB_OVERRIDE_NEW \ 464 static void* operator new(size_t size); \ 465 static void operator delete(void* ptr); \ 466 static void* operator new(size_t size, void* ptr) NLIB_NOEXCEPT; \ 467 static void operator delete(void* mem, void* ptr) NLIB_NOEXCEPT; \ 468 static void* operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT; \ 469 static void operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT 472 #ifndef NLIB_OVERRIDE_NEW_LIBNEW_CPP 473 #define NLIB_OVERRIDE_NEW_LIBNEW_CPP(type) \ 474 void* type::operator new(size_t size) { return ::operator new(size); } \ 475 void type::operator delete(void* ptr) { ::operator delete(ptr); } \ 476 void* type::operator new(size_t size, void* ptr) NLIB_NOEXCEPT { \ 477 return ::operator new(size, ptr); \ 479 void type::operator delete(void* mem, void* ptr) NLIB_NOEXCEPT { \ 480 ::operator delete(mem, ptr); \ 482 void* type::operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT { \ 483 return ::operator new(size, nt); \ 485 void type::operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT { \ 487 ::operator delete(mem); \ 505 bool operator!()
const;
511 return lhs.operator
errno_t() == rhs;
515 return rhs.operator
errno_t() == lhs;
519 return lhs.operator
errno_t() != rhs;
523 return rhs.operator
errno_t() != lhs;
532 const char& operator[](
size_t idx)
const NLIB_NOEXCEPT {
return str_[idx]; }
543 operator const char*()
const NLIB_NOEXCEPT {
return &str_[0]; }
544 const char& operator[](
size_t idx)
const NLIB_NOEXCEPT {
return str_[idx]; }
545 char& operator[](
size_t idx)
NLIB_NOEXCEPT {
return str_[idx]; }
560 _Printf_format_string_
const char* fmt,
569 _Printf_format_string_
const char* fmt,
582 _Printf_format_string_
const wchar_t* fmt,
591 _Printf_format_string_
const wchar_t* fmt,
604 _Printf_format_string_
const char* fmt,
606 return nlib_vsnprintf_fallback(count, buf, N, fmt, args);
613 _Printf_format_string_
const char* fmt,
617 errno_t e = nlib_vsnprintf_fallback(count, buf, N, fmt, args);
626 _Printf_format_string_
const wchar_t* fmt,
628 return nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
635 _Printf_format_string_
const wchar_t* fmt,
639 errno_t e = nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
718 size_t* to_count,
size_t* from_count,
725 size_t* to_count,
size_t* from_count,
732 size_t* to_count,
size_t* from_count,
739 size_t* to_count,
size_t* from_count,
746 size_t* to_count,
size_t* from_count,
753 size_t* to_count,
size_t* from_count,
759 #if !defined(NN_PLATFORM_CTR) && !defined(CAFE) 769 #ifdef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS 770 return !obj.operator bool();
775 #ifdef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS 783 #endif // __cplusplus 785 #if defined(_MSC_VER) 786 #if defined(n_EXPORTS) 787 #undef NLIB_VIS_PUBLIC 788 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 789 #elif defined(nx_misc_EXPORTS) 790 #undef NLIB_VIS_PUBLIC 791 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 795 #endif // INCLUDE_NN_NLIB_CONFIG_H_
Class that wraps the char array storing UTF-8. This class improves visual representations of UTF-8 in...
bool operator==(const HeapHash &rhs, const HeapHash &lhs)
Returns true if the two compared summaries are equal.
bool operator!=(const HeapHash &rhs, const HeapHash &lhs)
Returns true if the two compared summaries are not equal.
An empty structure indicating that an argument to a function needs to be moved.
Class that wraps errno_t. This class improves visual representations in the Visual Studio debugger...
Implements stream-related classes usually commonly used, various containers, and other gadget classes...
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
Class that wraps const char* storing UTF-8. This class improves visual representations of UTF-8 in th...
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
#define NLIB_STATIC_ASSERT(exp)
Defines a static assertion. Uses static_assert if it is available for use.