📄 _defs.h
字号:
# ifndef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
# define _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
# endif
# define _RWSTD_SIMPLE_DEFAULT(a)
# define _RWSTD_COMPLEX_DEFAULT(a)
# ifndef _RWSTD_NO_DEFAULT_TEMPLATES
# define _RWSTD_NO_DEFAULT_TEMPLATES
# endif
#endif // _RWSTD_NO_SIMPLE_DEFAULT_TEMPLATES
// Macro for casting, using either the "old" method
// or the new C++ cast system
#ifdef _RWSTD_NO_STATIC_CAST
# define _RWSTD_STATIC_CAST(x, y) ((x)y)
# define _RWSTD_REINTERPRET_CAST(x, y) ((x)y)
# define _RWSTD_CONST_CAST(x, y) ((x)y)
#else
# define _RWSTD_STATIC_CAST(x, y) static_cast< x >(y)
# define _RWSTD_REINTERPRET_CAST(x, y) reinterpret_cast< x >(y)
# define _RWSTD_CONST_CAST(x, y) const_cast< x >(y)
#endif // _RWSTD_NO_STATIC_CAST
//
// Macros for the new template specialization syntax
//
#ifdef _RWSTD_NO_NEW_FUNC_TEMPLATE_SYNTAX
# define _RWSTD_SPECIALIZED_FUNCTION
#else
# define _RWSTD_SPECIALIZED_FUNCTION template<>
#endif
#ifdef _RWSTD_NO_NEW_CLASS_TEMPLATE_SYNTAX
# define _RWSTD_SPECIALIZED_CLASS
#else
# define _RWSTD_SPECIALIZED_CLASS template<>
#endif
// for compilers or environments that do not support namespaces
#ifndef _RWSTD_NO_NAMESPACE
# define _RWSTD_NAMESPACE_BEGIN(name) namespace name {
# define _RWSTD_NAMESPACE_END }
# define _USING(name) using name
# ifdef _MSC_VER
# define _STD ::std
# define _STD_RW ::std
# define _RW ::__rw
# else
# define _STD std
# define _STD_RW std
# define _RW __rw
# endif
#else // if defined (_RWSTD_NO_NAMESPACE)
# define _RWSTD_NAMESPACE_BEGIN(ignore)
# define _RWSTD_NAMESPACE_END
# define _USING(ignore) typedef void __rw_unused_typedef
# define _STD
# define _STD_RW
# define _RW
#endif // _RWSTD_NO_NAMESPACE
//
// for compilers that don't like specialized friends
// such as operator== in template classes
//
#ifdef _RWSTD_NO_SPECIALIZED_FRIEND
# ifdef __TURBOC__
# define _RWSTD_SPECIALIZED_FRIEND(name) (_STD_RW::name)
# else // if !defined (__TURBOC__)
# define _RWSTD_SPECIALIZED_FRIEND(name) name
# endif // __TURBOC__
#else // if defined (_RWSTD_NO_SPECIALIZED_FRIEND)
# ifdef __TURBOC__
# define _RWSTD_SPECIALIZED_FRIEND(name) (_STD_RW::name)
# else // if !defined (__TURBOC__)
// the space between `name' and `<>' is necessary
// to prevent ..._FRIEND (operator<) from expanding into operator<<>
// (only the GNU preprocessor inserts a space)
# define _RWSTD_SPECIALIZED_FRIEND(name) name <>
# endif // __TURBOC__
#endif // _RWSTD_NO_SPECIALIZED_FRIEND
//
// If compiler supports member and default templates then it support
// the _RWSTD_ALLLOCATOR
//
#if !defined(_RWSTD_NO_MEMBER_TEMPLATES) \
&& !defined(_RWSTD_NO_SIMPLE_DEFAULT_TEMPLATES) \
&& !defined(_RWSTD_NO_MEM_CLASS_TEMPLATES)
# define _RWSTD_ALLOCATOR
#endif
#define _RWSTD_MB_CUR_MAX 16 //??? Need to find absolute maximum for this
// helper macros for token pasting
#define _RWSTD_DO_PASTE(a, b) a ## b
#define _RWSTD_PASTE(a, b) _RWSTD_DO_PASTE (a, b)
#ifdef _RWSTD_MULTI_THREAD
// synchronizes access by all objects holding the same mutex
# define _RWSTD_MT_GUARD(mutex) \
_RW::__rw_guard _RWSTD_PASTE (__guard, __LINE__) (mutex)
// synchronizes access by all threads
# define _RWSTD_MT_STATIC_GUARD(name) \
static _RW::__rw_mutex name; \
_RWSTD_MT_GUARD (name)
// synchronizes access by all objects of the same type
# define _RWSTD_MT_CLASS_GUARD(name, type) \
_RWSTD_MT_GUARD (_RW::__rw_get_static_mutex ((type*)0))
# define _RWSTD_ATOMIC_PREINCREMENT(x, mutex) \
_RW::__rw_atomic_preincrement (x, mutex)
# define _RWSTD_ATOMIC_PREDECREMENT(x, mutex) \
_RW::__rw_atomic_predecrement (x, mutex)
# define _RWSTD_ATOMIC_SWAP(x, y, mutex) \
_RW::__rw_atomic_exchange (x, y, mutex)
# ifndef _RWSTD_NO_EXT_REENTRANT_IO
// conditional swap used in iostreams
# define _RWSTD_ATOMIC_IO_SWAP(x, y, mutex) \
((this->flags () & _RWSTD_IOS_NOLOCK) ? \
_RW::__rw_ordinary_exchange (x, y) \
: _RW::__rw_atomic_exchange (x, y, mutex))
# else
# define _RWSTD_ATOMIC_IO_SWAP(x, y, mutex) \
_RWSTD_ATOMIC_SWAP(x, y, mutex)
# endif // _RWSTD_NO_EXT_REENTRANT_IO
#else // if !defined _RWSTD_MULTI_THREAD
# define _RWSTD_MT_GUARD(ignore) ((void)0)
# define _RWSTD_MT_STATIC_GUARD(name) _RWSTD_MT_GUARD (name)
# define _RWSTD_MT_CLASS_GUARD(name, ignore) _RWSTD_MT_GUARD (name)
# define _RWSTD_ATOMIC_PREINCREMENT(x, ignore) ++(x)
# define _RWSTD_ATOMIC_PREDECREMENT(x, ignore) --(x)
# define _RWSTD_ATOMIC_SWAP(x, y, ignore) \
_RW::__rw_atomic_exchange ((x), (y), false)
# define _RWSTD_ATOMIC_IO_SWAP(x, y, ignore) \
_RW::__rw_ordinary_exchange ((x), (y))
#endif // _RWSTD_MULTI_THREAD
// macro for qualifying C library names in the std namespace
#ifndef _RWSTD_NO_LIBC_IN_STD
# define _RWSTD_C std
#else
# define _RWSTD_C
#endif
#define _RWSTD_INVALID_FILE_DESC -1
#define _RWSTD_INVALID_FILE_PTR 0
#ifndef _RWSTD_NO_NATIVE_IO
# define _RWSTD_INVALID_FILE -1
# define _RWSTD_INVALID_OPENMODE -1
#else
# define _RWSTD_INVALID_FILE (FILE*)0
# define _RWSTD_INVALID_OPENMODE 0
#endif // _RWSTD_NO_NATIVE_IO
// std::ios_base static const data members' values
#define _RWSTD_IOS_BOOLALPHA 0x00001
#define _RWSTD_IOS_DEC 0x00002
#define _RWSTD_IOS_FIXED 0x00004
#define _RWSTD_IOS_HEX 0x00008
#define _RWSTD_IOS_INTERNAL 0x00010
#define _RWSTD_IOS_LEFT 0x00020
#define _RWSTD_IOS_OCT 0x00040
#define _RWSTD_IOS_RIGHT 0x00080
#define _RWSTD_IOS_SCIENTIFIC 0x00100
#define _RWSTD_IOS_SHOWBASE 0x00200
#define _RWSTD_IOS_SHOWPOINT 0x00400
#define _RWSTD_IOS_SHOWPOS 0x00800
#define _RWSTD_IOS_SKIPWS 0x01000
#define _RWSTD_IOS_UNITBUF 0x02000
#define _RWSTD_IOS_UPPERCASE 0x04000
#define _RWSTD_IOS_BIN 0x08000
// NOLOCK[BUF] used rather than LOCK[BUF] to maintain functional compatibility
// with release 2.2 (which was always safe when these bits were cleared)
#define _RWSTD_IOS_NOLOCK 0x10000
#define _RWSTD_IOS_NOLOCKBUF 0x20000
#define _RWSTD_IOS_FLOATFIELD _RWSTD_IOS_FIXED | _RWSTD_IOS_SCIENTIFIC
#define _RWSTD_IOS_ADJUSTFIELD \
(_RWSTD_IOS_LEFT | _RWSTD_IOS_RIGHT | _RWSTD_IOS_INTERNAL)
#ifndef _RWSTD_NO_EXT_BIN_IO
# define _RWSTD_IOS_BASEFIELD \
(_RWSTD_IOS_DEC | _RWSTD_IOS_HEX | _RWSTD_IOS_OCT | _RWSTD_IOS_BIN)
#else
# define _RWSTD_IOS_BASEFIELD \
(_RWSTD_IOS_DEC | _RWSTD_IOS_HEX | _RWSTD_IOS_OCT)
#endif // _RWSTD_NO_EXT_BIN_IO
#define _RWSTD_IOS_GOODBIT 0x00
#define _RWSTD_IOS_BADBIT 0x01
#define _RWSTD_IOS_EOFBIT 0x02
#define _RWSTD_IOS_FAILBIT 0x04
#define _RWSTD_IOS_APP 0x01
#define _RWSTD_IOS_BINARY 0x02
#define _RWSTD_IOS_IN 0x04
#define _RWSTD_IOS_OUT 0x08
#define _RWSTD_IOS_TRUNC 0x10
#define _RWSTD_IOS_ATE 0x20
#ifndef _RWSTD_STRICT_ANSI
# define _RWSTD_IOS_NOCREATE 0x40
# define _RWSTD_IOS_NOREPLACE 0x80
#else
# define _RWSTD_IOS_NOCREATE 0
# define _RWSTD_IOS_NOREPLACE 0
#endif
#define _RWSTD_IOS_MASK \
( _RWSTD_IOS_APP | _RWSTD_IOS_BINARY \
| _RWSTD_IOS_IN | _RWSTD_IOS_OUT \
| _RWSTD_IOS_TRUNC | _RWSTD_IOS_ATE \
| _RWSTD_IOS_NOCREATE | _RWSTD_IOS_NOREPLACE)
#if !defined (_RWSTD_NO_STATIC_IOSTREAM_INIT) \
&& !defined (_RWSTD_NO_IOSTREAM_OBJECT_REFS)
// standard iostream objects are references
# define _RWSTD_IOSTREAM_OBJECT(name) &name
#else
// standard iostream objects are declared to be real objects
// they may be implemented as real objects of the same type
// that get destroyed during program lifetime or as objects
// of some POD type that do not get destroyed at all
# define _RWSTD_IOSTREAM_OBJECT(name) name
#endif // _RWSTD_NO_STATIC_IOSTREAM_INIT && !_RWSTD_NO_IOSTREAM_OBJECT_REFS
// exceptions can be completely disabled (bodies of catch blocks are still
// compiled but will be removed by the optimizing stage of the compiler)
// this approach reveals any errors even if _RWSTD_NO_EXCEPTIONS is #defined
#ifndef _RWSTD_NO_EXCEPTIONS
# define _TRY try
# define _CATCH(ex) catch (ex)
# define _CATCH_T(ex) catch (ex)
# define _THROW(ex) throw ex
# define _RETHROW throw
#else // if defined (_RWSTD_NO_EXCEPTIONS)
# define _TRY
# define _CATCH(ignore) while (0)
# define _CATCH_T(type) for (type; 0;)
# define _THROW(ignore) ((void)0)
# define _RETHROW ((void)0)
#endif // _RWSTD_NO_EXCEPTIONS
// for compilers that can't handle standard allocators we provide four
// workarounds: _RWSTD_REBIND, used in place of _Allocator::rebind, allows
// containers to use the same allocator for different data types
// _RWSTD_ALLOC_TYPE is required to "rebind", or rather wrap, the user
// supplied non-conforming allocator in allocator_interface so that the
// container need not be aware of the allocator's special properties (namely
// the fact that the allocator allocates in terms of bytes rather than
// elemements)
//
// _RWSTD_VALUE_ALLOC creates a temporary allocator_interface wrapper
// from the given parameter (usually *this) when allocating values in
// the sequence containers with non-conforming allocators.
// _RWSTD_VALUE_ALLOC_CAST casts the given container to a reference to
// a value allocator, allowing access to inherited allocator members
// outside of the class. For non-conforming compilers, this macro is
// equivalent to _RWSTD_VALUE_ALLOC.
//
// NOTE: the spaces around type below are necessary to prevent errors
// if `to' is a template-id and the preprocessor doesn't put
// the spaces there automatically (GNU does, Sun does not)
#ifdef _RWSTD_ALLOCATOR
# define _RWSTD_REBIND(from, to) \
_TYPENAME from::template rebind < to >::other
# define _RWSTD_ALLOC_TYPE(_Allocator, _ValueType) _Allocator
# define _RWSTD_VALUE_ALLOC(ignore, call) allocator_type::call
# define _RWSTD_VALUE_ALLOC_CAST(rvalue) \
_RWSTD_STATIC_CAST (allocator_type&, rvalue)
#else // if !defined (_RWSTD_ALLOCATOR)
# define _RWSTD_REBIND(from, to) \
_STD_RW::allocator_interface < from, to >
# define _RWSTD_ALLOC_TYPE(_Allocator, _ValueType) \
_RWSTD_REBIND (_Allocator, _ValueType)
# define _RWSTD_VALUE_ALLOC(type, call) type(*this).call
# define _RWSTD_VALUE_ALLOC_CAST(rvalue) _C_value_alloc_type(rvalue)
#endif // _RWSTD_ALLOCATOR
// for compilers that can't deal with template functions parametrized
// on the function's return type (as opposed to function arguments)
//
// NOTE: the spaces around type below are necessary to prevent errors
// if `type' is a template-id and the preprocessor doesn't put
// the spaces there automatically (GNU does, Sun does not)
#ifndef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
# define _STD_USE_FACET(type, arg) _STD::use_facet < type >(arg)
# define _USE_FACET(type, arg) use_facet < type >(arg)
# define _GET_TEMP_BUFFER(type, size) get_temporary_buffer < type >(size)
#else // if defined (_RWSTD_NO_TEMPLATE_ON_RETURN_TYPE)
# define _STD_USE_FACET(type, arg) _STD::use_facet (arg, (type*)(0))
# define _USE_FACET(type, arg) use_facet (arg, (type*)(0))
# define _GET_TEMP_BUFFER(type, size) get_temporary_buffer (size, (type*)0)
#endif // _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
#ifndef _RWSTD_NO_NONCLASS_ARROW_RETURN
// expected signature: "_TypeT* operator->()"
// and/or: "const _TypeT* operator->() const"
# define _RWSTD_OPERATOR_ARROW(signature) signature { return &**this; }
#else
# define _RWSTD_OPERATOR_ARROW(ignore)
#endif // _RWSTD_NO_NONCLASS_ARROW_RETURN
// to prevent warnings about unused arguments
#define _RWSTD_UNUSED(arg) ((void)&arg)
// allows all externs to be declared/defined only in headers
// and defined just by first #defining _RWSTD_DEFINE_EXTERNS
// and then #including the header in a .cpp file
#ifndef _RWSTD_DEFINE_EXTERNS
# define _RWSTD_EXTERN(decl, ignore) extern decl
#else
# define _RWSTD_EXTERN(decl, value) extern decl = value
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -