#ifndef VCZH_BASIC
#define VCZH_BASIC
#ifdef VCZH_CHECK_MEMORY_LEAKS
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define VCZH_CHECK_MEMORY_LEAKS_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new VCZH_CHECK_MEMORY_LEAKS_NEW
#endif
#if defined _WIN64 || __x86_64 || __LP64__
#define VCZH_64
#endif
#if defined _MSC_VER
#define VCZH_MSVC
#else
#define VCZH_GCC
#if defined(__APPLE__)
#define VCZH_APPLE
#endif
#endif
#if defined VCZH_CLANG_AST_DUMP
#define abstract
#endif
#if defined VCZH_MSVC
#include <intrin.h>
#elif defined VCZH_GCC
#include <x86intrin.h>
#include <stdint.h>
#include <stddef.h>
#include <wchar.h>
#define abstract
#define __thiscall
#define __forceinline inline
#define _I8_MIN ((vint8_t)0x80)
#define _I8_MAX ((vint8_t)0x7F)
#define _UI8_MAX ((vuint8_t)0xFF)
#define _I16_MIN ((vint16_t)0x8000)
#define _I16_MAX ((vint16_t)0x7FFF)
#define _UI16_MAX ((vuint16_t)0xFFFF)
#define _I32_MIN ((vint32_t)0x80000000)
#define _I32_MAX ((vint32_t)0x7FFFFFFF)
#define _UI32_MAX ((vuint32_t)0xFFFFFFFF)
#define _I64_MIN ((vint64_t)0x8000000000000000L)
#define _I64_MAX ((vint64_t)0x7FFFFFFFFFFFFFFFL)
#define _UI64_MAX ((vuint64_t)0xFFFFFFFFFFFFFFFFL)
#endif
#define L_(x) L__(x)
#define L__(x) L ## x
namespace
{
#if defined VCZH_MSVC
typedef
signed
__int8
;
typedef
unsigned
__int8
;
typedef
signed
__int16
;
typedef
unsigned
__int16
;
typedef
signed
__int32
;
typedef
unsigned
__int32
;
typedef
signed
__int64
;
typedef
unsigned
__int64
;
#elif defined VCZH_GCC
typedef int8_t vint8_t;
typedef uint8_t vuint8_t;
typedef int16_t vint16_t;
typedef uint16_t vuint16_t;
typedef int32_t vint32_t;
typedef uint32_t vuint32_t;
typedef int64_t vint64_t;
typedef uint64_t vuint64_t;
#endif
#ifdef VCZH_64
/// <summary>Signed interface whose size equals to sizeof(void*).</summary>
typedef vint64_t vint;
/// <summary>Signed interface whose size equals to sizeof(void*).</summary>
typedef vint64_t vsint;
/// <summary>Unsigned interface whose size equals to sizeof(void*).</summary>
typedef vuint64_t vuint;
#else
typedef
;
typedef
;
typedef
;
#endif
typedef
;
#ifdef VCZH_64
#define ITOA_S _i64toa_s
#define ITOW_S _i64tow_s
#define I64TOA_S _i64toa_s
#define I64TOW_S _i64tow_s
#define UITOA_S _ui64toa_s
#define UITOW_S _ui64tow_s
#define UI64TOA_S _ui64toa_s
#define UI64TOW_S _ui64tow_s
#if defined VCZH_MSVC
#define INCRC(x) (_InterlockedIncrement64(x))
#define DECRC(x) (_InterlockedDecrement64(x))
#elif defined VCZH_GCC
#define INCRC(x) (__sync_add_and_fetch(x, 1))
#define DECRC(x) (__sync_sub_and_fetch(x, 1))
#endif
#else
#define ITOA_S _itoa_s
#define ITOW_S _itow_s
#define I64TOA_S _i64toa_s
#define I64TOW_S _i64tow_s
#define UITOA_S _ui64toa_s
#define UITOW_S _ui64tow_s
#define UI64TOA_S _ui64toa_s
#define UI64TOW_S _ui64tow_s
#if defined VCZH_MSVC
#define INCRC(x) (_InterlockedIncrement((volatile long*)(x)))
#define DECRC(x) (_InterlockedDecrement((volatile long*)(x)))
#elif defined VCZH_GCC
#define INCRC(x) (__sync_add_and_fetch(x, 1))
#define DECRC(x) (__sync_sub_and_fetch(x, 1))
#endif
#endif
class
{
private
:
(
const
&);
&
(
const
&);
public
:
();
};
class
{
private
:
const
wchar_t
*
;
public
:
(
const
wchar_t
*
);
const
wchar_t
*
()
const
;
};
#if defined VCZH_MSVC || defined VCZH_GCC || defined _DEBUG
#define CHECK_ERROR(CONDITION,DESCRIPTION) do{if(!(CONDITION))throw Error(DESCRIPTION);}while(0)
#elif defined NDEBUG
#define CHECK_ERROR(CONDITION,DESCRIPTION)
#endif
#define CHECK_FAIL(DESCRIPTION) do{throw Error(DESCRIPTION);}while(0)
#define SCOPE_VARIABLE(TYPE, VARIABLE, VALUE)\
if(bool __scope_variable_flag__=true)\
for(TYPE VARIABLE = VALUE;__scope_variable_flag__;__scope_variable_flag__=false)
template
<
typename
>
struct
{
typedef
;
};
template
<
typename
>
struct
<
&>
{
typedef
;
};
template
<
typename
>
struct
<
&&>
{
typedef
;
};
template
<
typename
>
struct
{
typedef
;
};
template
<
typename
>
struct
<
const
>
{
typedef
;
};
template
<
typename
>
struct
{
typedef
;
};
template
<
typename
>
struct
<
volatile
>
{
typedef
;
};
template
<
typename
>
struct
{
typedef
;
};
template
<
typename
>
struct
<
&>
{
typedef
typename
<
>::
;
};
template
<
typename
>
struct
<
&&>
{
typedef
typename
<
>::
;
};
template
<
typename
>
struct
<
const
>
{
typedef
typename
<
>::
;
};
template
<
typename
>
struct
<
volatile
>
{
typedef
typename
<
>::
;
};
template
<
typename
>
typename
<
>::
&&
(
&&
)
{
return
(
typename
<
>::
&&)
;
}
template
<
typename
>
&&
(
typename
<
>::
&&
)
{
return
(
&&)
;
}
template
<
typename
>
&&
(
typename
<
>::
&
)
{
return
(
&&)
;
}
template
<
typename
...
>
struct
{
};
class
{
public
:
virtual
();
};
template
<
typename
>
class
:
public
{
private
:
;
public
:
(
const
&
)
:object(
)
{
}
(
&&
)
:object(
(
))
{
}
(
const
<
>&
) =
default
;
(
<
>&&
) =
default
;
<
>&
(
const
&
)
{
=
;
return
*
this
;
}
<
>&
(
const
<
>&
) =
default
;
<
>&
(
<
>&&
) =
default
;
const
&
()
{
return
;
}
};
template
<
typename
>
class
{
private
:
*
=
nullptr
;
public
:
() =
default
;
(
const
&
)
:object(
new
(
))
{
}
(
&&
)
:object(
new
(
(
)))
{
}
(
const
<
>&
)
:object(
.
?
new
(*
.
) :
nullptr
)
{
}
(
<
>&&
)
:object(
.
)
{
.
=
nullptr
;
}
()
{
if
(
)
delete
;
}
<
>&
(
const
&
)
{
if
(
)
delete
;
=
new
(
);
return
*
this
;
}
<
>&
(
const
<
>&
)
{
if
(
this
!= &
)
{
if
(
)
delete
;
if
(
.
)
{
=
new
(*
.
);
}
else
{
=
nullptr
;
}
}
return
*
this
;
}
<
>&
(
<
>&&
)
{
if
(
this
!= &
)
{
if
(
)
delete
;
=
.
;
.
=
nullptr
;
}
return
*
this
;
}
static
bool
(
const
<
>&
,
const
<
>&
)
{
if
(!
.
&& !
.
)
return
true
;
if
(
.
&&
.
)
return
*
.
== *
.
;
return
false
;
}
static
(
const
<
>&
,
const
<
>&
)
{
if
(
.
&&
.
)
{
if
(*
.
> *
.
)
return
1
;
if
(*
.
< *
.
)
return
-
1
;
return
0
;
}
if
(
.
)
return
1
;
if
(
.
)
return
-
1
;
return
0
;
}
bool
(
const
<
>&
)
const
{
return
(*
this
,
);
}
bool
(
const
<
>&
)
const
{
return
!
(*
this
,
);
}
bool
(
const
<
>&
)
const
{
return
(*
this
,
) <
0
;
}
bool
(
const
<
>&
)
const
{
return
(*
this
,
) <=
0
;
}
bool
(
const
<
>&
)
const
{
return
(*
this
,
) >
0
;
}
bool
(
const
<
>&
)
const
{
return
(*
this
,
) >=
0
;
}
bool
()
const
{
return
!=
nullptr
;
}
const
&
()
const
{
if
(!
)
throw
(
L"Nullable<T>::Value()#Cannot unbox from null."
);
return
*
;
}
};
template
<
typename
,
>
union
{
;
char
[
sizeof
(
) >
?
sizeof
(
) :
];
};
template
<
typename
>
struct
{
public
:
typedef
;
static
const
&
(
const
&
)
{
return
;
}
};
template
<
typename
>
struct
{
static
const
bool
=
false
;
};
template
<>
struct
<
bool
> {
static
const
bool
=
true
; };
template
<>
struct
<
> {
static
const
bool
=
true
; };
template
<>
struct
<
> {
static
const
bool
=
true
; };
template
<>
struct
<
> {
static
const
bool
=
true
; };
template
<>
struct
<
> {
static
const
bool
=
true
; };
template
<>
struct
<
> {
static
const
bool
=
true
; };
template
<>
struct
<
> {
static
const
bool
=
true
; };
template
<>
struct
<
> {
static
const
bool
=
true
; };
template
<>
struct
<
> {
static
const
bool
=
true
; };
template
<>
struct
<
char
> {
static
const
bool
=
true
; };
template
<>
struct
<
wchar_t
> {
static
const
bool
=
true
; };
template
<
typename
>
struct
<
*> {
static
const
bool
=
true
; };
template
<
typename
>
struct
<
&> {
static
const
bool
=
true
; };
template
<
typename
>
struct
<
&&> {
static
const
bool
=
true
; };
template
<
typename
,
typename
>
struct
<
::*> {
static
const
bool
=
true
; };
template
<
typename
,
>
struct
<
[
]> {
static
const
bool
=
<
>::
; };
template
<
typename
>
struct
<
const
> {
static
const
bool
=
<
>::
; };
template
<
typename
>
struct
<
volatile
> {
static
const
bool
=
<
>::
; };
template
<
typename
>
struct
<
const
volatile
> {
static
const
bool
=
<
>::
; };
struct
{
;
;
;
;
;
;
;
;
;
;
static
();
static
();
static
(
,
,
,
=
0
,
=
0
,
=
0
,
=
0
);
static
(
);
();
();
();
(
);
(
);
bool
(
const
&
)
const
{
return
==
.
; }
bool
(
const
&
)
const
{
return
!=
.
; }
bool
(
const
&
)
const
{
return
<
.
; }
bool
(
const
&
)
const
{
return
<=
.
; }
bool
(
const
&
)
const
{
return
>
.
; }
bool
(
const
&
)
const
{
return
>=
.
; }
};
class
:
private
{
public
:
virtual
();
};
struct
{};
struct
{};
template
<
typename
,
typename
>
struct
{
};
template
<
typename
>
struct
<
,
>
{
typedef
;
};
template
<
typename
,
typename
>
struct
{
typedef
;
};
template
<>
struct
<
,
>
{
typedef
;
};
template
<
typename
,
typename
>
struct
{
typedef
;
};
template
<>
struct
<
,
>
{
typedef
;
};
template
<
typename
>
struct
{
static
const
bool
=
false
;
};
template
<>
struct
<
>
{
static
const
bool
=
true
;
};
template
<
typename
>
();
template
<
typename
,
typename
>
struct
{
static
(
*
);
static
(
void
*
);
typedef
decltype
(
(
<
*>()))
;
};
template
<
typename
,
typename
>
struct
{
static
(
&&
);
static
(...);
typedef
decltype
(
(
<
&&>()))
;
};
template
<
typename
>
struct
<
,
void
>
{
typedef
;
};
template
<
typename
>
struct
<
void
,
>
{
typedef
;
};
template
<>
struct
<
void
,
void
>
{
typedef
;
};
template
<
typename
,
typename
>
struct
{
typedef
;
};
}
#endif