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 __cpp_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 __cpp_constexpr 93 # define NLIB_CEXPR constexpr 94 # if __cpp_constexpr >= 201304L 95 # define NLIB_CEXPR14 constexpr 101 # define NLIB_CEXPR14 105 #define NLIB_NOEXCEPT noexcept 106 #define NLIB_NOEXCEPT_FUNCPTR 107 #define NLIB_CEXPR constexpr 108 #define NLIB_CEXPR14 constexpr 109 #define NLIB_DEPRECATED [[deprecated]] // NOLINT 110 #define NLIB_DEPRECATED_MSG(x) [[deprecated(x)]] // NOLINT 113 #ifndef NLIB_NOEXCEPT 114 #ifdef NLIB_CXX11_NOEXCEPT 115 # define NLIB_NOEXCEPT noexcept 117 # define NLIB_NOEXCEPT throw() 119 #elif defined(__INTELLISENSE__) 120 # undef NLIB_NOEXCEPT 121 # define NLIB_NOEXCEPT 124 #ifndef NLIB_NOEXCEPT_FUNCPTR 125 #define NLIB_NOEXCEPT_FUNCPTR 128 struct nlib_unwind_exception {};
129 #ifndef NLIB_RETHROW_UNWIND 130 # define NLIB_RETHROW_UNWIND catch (nlib_unwind_exception&) 133 #ifndef NLIB_ASSERT_NOERR 134 # define NLIB_ASSERT_NOERR(e) NLIB_ASSERT((e) == 0) 137 #ifdef __cpp_exceptions 138 # define NLIB_TRY try 139 # define NLIB_CATCH(x) catch(x) 140 # define NLIB_THROW throw 142 # define NLIB_TRY if (true) 143 # define NLIB_CATCH(x) if (false) 147 #ifndef NLIB_STATIC_ASSERT 148 #ifndef __cpp_static_assert 152 struct STATIC_ASSERTION_FAILURE;
154 struct STATIC_ASSERTION_FAILURE<true> {};
156 struct static_assert_test {};
160 #define NLIB_ASSERT_H_STRING_JOIN_(X, Y) NLIB_ASSERT_H_STRING_JOIN1_(X, Y) 161 #define NLIB_ASSERT_H_STRING_JOIN1_(X, Y) X##Y 163 #define NLIB_STATIC_ASSERT(exp) \ 164 typedef ::nlib_ns::detail::static_assert_test< \ 165 sizeof(::nlib_ns::detail::STATIC_ASSERTION_FAILURE<(exp) != 0>)> \ 166 NLIB_ASSERT_H_STRING_JOIN_(nn_static_assert_typedef_, __LINE__) 167 #elif __cpp_static_assert >= 201411L 168 # define NLIB_STATIC_ASSERT(exp) static_assert(exp) 170 # define NLIB_STATIC_ASSERT(exp) static_assert((exp), "NLIB_STATIC_ASSERT error: " #exp) 174 #ifndef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS 175 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 176 TypeName(const TypeName&); \ 177 void operator=(const TypeName&) 179 #define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName) \ 180 TypeName(const TypeName&) = delete; \ 181 void operator=(const TypeName&) = delete 184 #ifndef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS 185 #define NLIB_SAFE_BOOL(class_name, exp) \ 187 typedef void (class_name::*bool_type)() const; \ 188 void this_type_does_not_support_comparisons() const NLIB_NOEXCEPT {} \ 190 operator bool_type() const NLIB_NOEXCEPT { \ 191 return (exp) ? &class_name::this_type_does_not_support_comparisons : 0; \ 194 #define NLIB_SAFE_BOOL(class_name, exp) \ 196 explicit NLIB_ALWAYS_INLINE operator bool() const NLIB_NOEXCEPT { return (exp); } 200 #if defined(WCHAR_MIN) && defined(WCHAR_MAX) 201 # if WCHAR_MAX <= 0xFFFF 202 # define NLIB_WCHAR_SIZE (2) 205 # define NLIB_WCHAR_SIZE (4) 209 # error WCHAR_MIN, WCHAR_MAX not defined 212 #ifndef NLIB_CXX11_NULL_POINTER_CONSTANT 217 operator T*()
const {
220 template <
class C,
class T>
221 operator T C::*()
const {
226 void operator&()
const;
230 const nullptr_t
nullptr = {};
236 typedef std::nullptr_t nullptr_t;
240 #ifndef NLIB_CXX11_EXPLICIT_VIRTUAL_OVERRIDES 241 # define NLIB_OVERRIDE 244 # define NLIB_OVERRIDE override 245 # define NLIB_FINAL final 248 #ifdef NLIB_CXX11_ALIGNMENT_SUPPORT 255 # define NLIB_ALIGNAS(x) alignas(x) 256 # define NLIB_ALIGNOF(tp) alignof(tp) 259 #ifdef __cpp_rvalue_references 268 #ifdef __cpp_rvalue_references 269 #define NLIB_DEFMOVE_PIMPL(tp) \ 270 NLIB_ALWAYS_INLINE tp(tp&& rhs) NLIB_NOEXCEPT : prv_(rhs.prv_) { \ 271 rhs.prv_ = nullptr; \ 273 NLIB_ALWAYS_INLINE tp& operator=(tp&& rhs) NLIB_NOEXCEPT { \ 276 rhs.prv_ = nullptr; \ 280 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : prv_(rhs.prv_) { \ 281 rhs.prv_ = nullptr; \ 284 tp& assign(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT { \ 287 rhs.prv_ = nullptr; \ 291 #define NLIB_DEFMOVE_PIMPL(tp) \ 293 tp(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT : prv_(rhs.prv_) { \ 294 rhs.prv_ = nullptr; \ 297 tp& assign(tp& rhs, ::nlib_ns::move_tag) NLIB_NOEXCEPT { \ 300 rhs.prv_ = nullptr; \ 305 #ifndef NLIB_MEMCHECKER 306 # define NLIB_MEMCHECKER NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT 307 # define NLIB_MEMCHECKER_START NLIB_STATIC_ASSERT(sizeof(char) == 1) // NOLINT 308 # define NLIB_MEMCHECKER_CHECK true 313 #ifndef NLIB_NOEMPTYFILE 314 # define NLIB_NOEMPTYFILE() 317 #ifdef NLIB_SOCKET_ENABLED 321 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 50) 323 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER) 327 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 75) 329 # define NLIB_SOCKPORT_SAMPLE (17974 + _MSC_VER + 25) 332 # elif defined(__clang__) 334 # define NLIB_SOCKPORT_SAMPLE (18174) 336 # define NLIB_SOCKPORT_SAMPLE (18074) 340 # define NLIB_SOCKPORT_SAMPLE (17874) 342 # define NLIB_SOCKPORT_SAMPLE (17974) 355 #if !defined(NLIB_CIBUILD) && defined(NDEBUG) 356 # define NLIB_TESTLOOPCOUNT(x) (x) 358 # define NLIB_TESTLOOPCOUNT(x) (1) 361 #ifndef NLIB_OVERRIDE_NEW 362 #define NLIB_OVERRIDE_NEW \ 363 static void* operator new(size_t size); \ 364 static void operator delete(void* ptr); \ 365 static void* operator new(size_t size, void* ptr) NLIB_NOEXCEPT; \ 366 static void operator delete(void* mem, void* ptr) NLIB_NOEXCEPT; \ 367 static void* operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT; \ 368 static void operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT 371 #ifndef NLIB_OVERRIDE_NEW_LIBNEW_CPP 372 #define NLIB_OVERRIDE_NEW_LIBNEW_CPP(type) \ 373 void* type::operator new(size_t size) { return ::operator new(size); } \ 374 void type::operator delete(void* ptr) { ::operator delete(ptr); } \ 375 void* type::operator new(size_t size, void* ptr) NLIB_NOEXCEPT { \ 376 return ::operator new(size, ptr); \ 378 void type::operator delete(void* mem, void* ptr) NLIB_NOEXCEPT { \ 379 ::operator delete(mem, ptr); \ 381 void* type::operator new(size_t size, const std::nothrow_t& nt) NLIB_NOEXCEPT { \ 382 return ::operator new(size, nt); \ 384 void type::operator delete(void* mem, const std::nothrow_t& nt) NLIB_NOEXCEPT { \ 386 ::operator delete(mem); \ 390 #define NLIB_EQUAL_OPERATOR(TP) \ 391 NLIB_ALWAYS_INLINE bool operator!=(const TP& lhs, const TP& rhs) NLIB_NOEXCEPT { \ 392 return !(lhs == rhs); \ 394 #define NLIB_COMPARE_OPERATOR(TP) \ 395 NLIB_ALWAYS_INLINE bool operator>(const TP& lhs, const TP& rhs) NLIB_NOEXCEPT { \ 398 NLIB_ALWAYS_INLINE bool operator<=(const TP& lhs, const TP& rhs) NLIB_NOEXCEPT { \ 399 return !(rhs < lhs); \ 401 NLIB_ALWAYS_INLINE bool operator>=(const TP& lhs, const TP& rhs) NLIB_NOEXCEPT { \ 402 return !(lhs < rhs); \ 419 bool operator!()
const;
425 return lhs.operator
errno_t() == rhs;
429 return rhs.operator
errno_t() == lhs;
433 return lhs.operator
errno_t() != rhs;
437 return rhs.operator
errno_t() != lhs;
446 const char& operator[](
size_t idx)
const NLIB_NOEXCEPT {
return str_[idx]; }
457 operator const char*()
const NLIB_NOEXCEPT {
return &str_[0]; }
458 const char& operator[](
size_t idx)
const NLIB_NOEXCEPT {
return str_[idx]; }
459 char& operator[](
size_t idx)
NLIB_NOEXCEPT {
return str_[idx]; }
474 _Printf_format_string_
const char* fmt,
483 _Printf_format_string_
const char* fmt,
496 _Printf_format_string_
const wchar_t* fmt,
505 _Printf_format_string_
const wchar_t* fmt,
518 _Printf_format_string_
const char* fmt,
520 return nlib_vsnprintf_fallback(count, buf, N, fmt, args);
527 _Printf_format_string_
const char* fmt,
531 errno_t e = nlib_vsnprintf_fallback(count, buf, N, fmt, args);
540 _Printf_format_string_
const wchar_t* fmt,
542 return nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
549 _Printf_format_string_
const wchar_t* fmt,
553 errno_t e = nlib_vsnwprintf_fallback(count, buf, N, fmt, args);
632 size_t* to_count,
size_t* from_count,
639 size_t* to_count,
size_t* from_count,
646 size_t* to_count,
size_t* from_count,
653 size_t* to_count,
size_t* from_count,
660 size_t* to_count,
size_t* from_count,
667 size_t* to_count,
size_t* from_count,
673 #if !defined(NN_PLATFORM_CTR) && !defined(CAFE) 683 #ifdef NLIB_CXX11_EXPLICIT_CONVERSION_OPERATORS 684 return !obj.operator bool();
689 #ifdef NLIB_CXX11_DEFAULTED_AND_DELETED_FUNCTIONS 697 #endif // __cplusplus 699 #if defined(_MSC_VER) 700 #if defined(n_EXPORTS) 701 #undef NLIB_VIS_PUBLIC 702 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 703 #elif defined(nx_misc_EXPORTS) 704 #undef NLIB_VIS_PUBLIC 705 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 709 #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.