// cstddef standard header
#ifndef _CSTDDEF_
#define _CSTDDEF_

#if defined(__ghs)

#include <yvals.h>
#include <stddef.h>

 #if defined(__GHS_PRAGMAS)
  #pragma ghs start_cxx_lib_header
  #pragma ghs startdata
 #endif
 #if defined(__ghs) && defined(__ghs_max_pack_value)
  #pragma pack (push, __ghs_max_pack_value)
 #endif

_STD_BEGIN
	using ::ptrdiff_t;
	using ::size_t;
    
 #if defined(__GHS_HAVE_MAX_ALIGN_T) // Check if stddef.h has already def'd this
	using ::max_align_t;	// most aligned type
 #else
	typedef union {
 #if defined(__LLONG_BIT)
		long long __max_align_ll;
 #else
		long __max_align_l;
 #endif /* defined(__LLONG_BIT) */
 #if !defined(__NoFloat) && !defined(__NoDouble)
		long double __max_align_ld;
 #endif /* !defined(__NoFloat) && !defined(__NoDouble) */
		unsigned char __max_align_attr __attribute__((aligned(__ghs_alignment)));
	} max_align_t;	// most aligned type
 #endif /* defined(__GHS_HAVE_MAX_ALIGN_T) */

 #if _HAS_CPP11
  #if defined(__GHS_HAVE_NULLPTR_T) // Check if stddef.h has already def'd this
	using ::nullptr_t;
  #else
	using nullptr_t = decltype(nullptr);
  #endif /* defined(__GHS_HAVE_NULLPTR_T) */
 #endif /* _HAS_CPP11 */

_STD_END

#endif /* defined(__ghs) */

_STD_BEGIN
	// TEMPLATE CLASS integral_constant
template<class _Ty,
	_Ty _Val>
	struct integral_constant
	{	// convenient template for integral constant types
	static _CONST_DATA _Ty value = _Val;

	typedef _Ty value_type;
	typedef integral_constant<_Ty, _Val> type;

	_CONST_FUN operator value_type() const _NOEXCEPT
		{	// return stored value
		return (value);
		}

	_CONST_FUN value_type operator()() const _NOEXCEPT
		{	// return stored value
		return (value);
		}
	};

#if defined(__ghs)
template <class _Ty,
	_Ty _Val>
_CONST_DATA _Ty integral_constant<_Ty, _Val>::value;
#endif /* defined(__ghs) */

typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;

	// TEMPLATE CLASS _Is_integral
template<class _Ty>
	struct _Is_integral
		: false_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<bool>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<char>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<unsigned char>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<signed char>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<wchar_t>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<unsigned short>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<signed short>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<unsigned int>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<signed int>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<unsigned long>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<signed long>
		: true_type
	{	// determine whether _Ty is integral
	};

 #if _HAS_CHAR16_T_LANGUAGE_SUPPORT
template<>
	struct _Is_integral<char16_t>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<char32_t>
		: true_type
	{	// determine whether _Ty is integral
	};
 #endif /* _HAS_CHAR16_T_LANGUAGE_SUPPORT */

 #ifdef _LONGLONG
template<>
	struct _Is_integral<_LONGLONG>
		: true_type
	{	// determine whether _Ty is integral
	};

template<>
	struct _Is_integral<_ULONGLONG>
		: true_type
	{	// determine whether _Ty is integral
	};
 #endif /* _LONGLONG */

	// TEMPLATE CLASS remove_const
template<class _Ty>
	struct remove_const
	{	// remove top level const qualifier
	typedef _Ty type;
	};

template<class _Ty>
	struct remove_const<const _Ty>
	{	// remove top level const qualifier
	typedef _Ty type;
	};

template<class _Ty>
	struct remove_const<const _Ty[]>
	{	// remove top level const qualifier
	typedef _Ty type[];
	};

template<class _Ty, size_t _Nx>
	struct remove_const<const _Ty[_Nx]>
	{	// remove top level const qualifier
	typedef _Ty type[_Nx];
	};

	// TEMPLATE CLASS remove_volatile
template<class _Ty>
	struct remove_volatile
	{	// remove top level volatile qualifier
	typedef _Ty type;
	};

template<class _Ty>
	struct remove_volatile<volatile _Ty>
	{	// remove top level volatile qualifier
	typedef _Ty type;
	};

template<class _Ty>
	struct remove_volatile<volatile _Ty[]>
	{	// remove top level volatile qualifier
	typedef _Ty type[];
	};

template<class _Ty, size_t _Nx>
	struct remove_volatile<volatile _Ty[_Nx]>
	{	// remove top level volatile qualifier
	typedef _Ty type[_Nx];
	};

	// TEMPLATE CLASS remove_cv
template<class _Ty>
	struct remove_cv
	{	// remove top level const and volatile qualifiers
	typedef typename remove_const<typename remove_volatile<_Ty>::type>::type
		type;
	};

	// TEMPLATE CLASS is_integral
template<class _Ty>
	struct is_integral
		: _Is_integral<typename remove_cv<_Ty>::type>
	{	// determine whether _Ty is integral
	};

	// TEMPLATE CLASS enable_if
template<bool _Test,
	class _Ty = void>
	struct enable_if
	{	// type is undefined for assumed !_Test
	};

template<class _Ty>
	struct enable_if<true, _Ty>
	{	// type is _Ty for _Test
	typedef _Ty type;
	};

 #if _HAS_CPP11
template<bool _Test,
	class _Ty = void>
	using enable_if_t = typename enable_if<_Test, _Ty>::type;
 #endif /* _HAS_CPP11 */

 #if _HAS_CPP17
  #if defined(__ghs)
    // For GHS, nullptr_t is defined further above.  Further it is defined in
    // C++11 mode and later.
  #else
using nullptr_t = decltype(nullptr);
  #endif /* defined(__ghs) */
	// CLASS byte

 #if _HAS_ENUM_CLASS
enum class byte : unsigned char {};
template<class _Itype,
	class = enable_if_t<is_integral<_Itype>::value,
		void> > inline
	_CONST_FUN byte operator<<(byte _Left, _Itype _Shift) _NOEXCEPT
	{	// shift left
	return (_STD byte((unsigned char)_Left << _Shift));
	}

template<class _Itype,
	class = enable_if_t<is_integral<_Itype>::value,
		void> > inline
	_CONST_FUN byte& operator<<=(byte& _Left, _Itype _Shift) _NOEXCEPT
	{	// shift left in place
	return (_Left = _Left << _Shift);
	}

template<class _Itype,
	class = enable_if_t<is_integral<_Itype>::value,
		void> > inline
	_CONST_FUN byte operator>>(byte _Left, _Itype _Shift) _NOEXCEPT
	{	// shift right
	return (_STD byte((unsigned char)_Left >> _Shift));
	}

template<class _Itype,
	class = enable_if_t<is_integral<_Itype>::value,
		void> > inline
	_CONST_FUN byte& operator>>=(byte& _Left, _Itype _Shift) _NOEXCEPT
	{	// shift right in place
	return (_Left = _Left >> _Shift);
	}

#if defined(__ghs)
inline
#endif /* defined(__ghs) */
_CONST_FUN byte operator|(byte _Left, byte _Right) _NOEXCEPT
	{	// OR
	return (_STD byte((unsigned char)_Left | (unsigned char)_Right));
	}

#if defined(__ghs)
inline
#endif /* defined(__ghs) */
_CONST_FUNX byte& operator|=(byte& _Left, byte _Right) _NOEXCEPT
	{	// OR in place
	return (_Left = _Left | _Right);
	}

#if defined(__ghs)
inline
#endif /* defined(__ghs) */
_CONST_FUN byte operator&(byte _Left, byte _Right) _NOEXCEPT
	{	// AND
	return (_STD byte((unsigned char)_Left & (unsigned char)_Right));
	}

#if defined(__ghs)
inline
#endif /* defined(__ghs) */
_CONST_FUNX byte& operator&=(byte& _Left, byte _Right) _NOEXCEPT
	{	// AND in place
	return (_Left = _Left & _Right);
	}

#if defined(__ghs)
inline
#endif /* defined(__ghs) */
_CONST_FUN byte operator^(byte _Left, byte _Right) _NOEXCEPT
	{	// XOR
	return (_STD byte((unsigned char)_Left ^ (unsigned char)_Right));
	}

#if defined(__ghs)
inline
#endif /* defined(__ghs) */
_CONST_FUNX byte& operator^=(byte& _Left, byte _Right) _NOEXCEPT
	{	// XOR in place
	return (_Left = _Left ^ _Right);
	}

#if defined(__ghs)
inline
#endif /* defined(__ghs) */
_CONST_FUN byte operator~(byte _Left) _NOEXCEPT
	{	// NOT
	return (_STD byte(~(unsigned char)_Left));
	}

 #else /* _HAS_ENUM_CLASS */
typedef unsigned char byte;
 #endif /* _HAS_ENUM_CLASS */

#if defined(__ghs)
template<class _Itype,
	class = enable_if_t<is_integral<_Itype>::value, void> >
#else
template<class _Itype>
#endif /* defined(__ghs) */
	_CONST_FUN _Itype to_integer(byte _Left) _NOEXCEPT
	{	// convert to integer
	return ((_Itype)_Left);
	}

#if defined(__ghs)
#define __cpp_lib_byte 201603L
#endif

 #endif /* _HAS_CPP17 */
_STD_END

 #if defined(__ghs) && defined(__ghs_max_pack_value)
  #pragma pack(pop)
 #endif
 #if defined(__GHS_PRAGMAS)
  #pragma ghs enddata
  #pragma ghs end_cxx_lib_header
 #endif

#endif /* _CSTDDEF_ */

/*
 * Copyright (c) by P.J. Plauger. All rights reserved.
 * Consult your license regarding permissions and restrictions.
V8.03b/17:0063 */
