/* Copyright (c) 2019-2024 Griefer@Work                                       *
 *                                                                            *
 * This software is provided 'as-is', without any express or implied          *
 * warranty. In no event will the authors be held liable for any damages      *
 * arising from the use of this software.                                     *
 *                                                                            *
 * Permission is granted to anyone to use this software for any purpose,      *
 * including commercial applications, and to alter it and redistribute it     *
 * freely, subject to the following restrictions:                             *
 *                                                                            *
 * 1. The origin of this software must not be misrepresented; you must not    *
 *    claim that you wrote the original software. If you use this software    *
 *    in a product, an acknowledgement (see the following) in the product     *
 *    documentation is required:                                              *
 *    Portions Copyright (c) 2019-2024 Griefer@Work                           *
 * 2. Altered source versions must be plainly marked as such, and must not be *
 *    misrepresented as being the original software.                          *
 * 3. This notice may not be removed or altered from any source distribution. *
 */
/* (>) Standard: ISO C++98 (ISO/IEC 14882:1998) */
/* (#) Portability: MSVC      (/include/utility) */
/* (#) Portability: libstdc++ (/include/utility) */
#ifndef _CXX_UTILITY
#define _CXX_UTILITY 1

#include <__stdcxx.h>
#include <features.h>

#include <initializer_list>

#ifdef __USE_ISOCXX11
#include <c++/bits/forward.h>
#include <c++/bits/move.h>
#include <c++/bits/traits/andor.h>
#include <c++/bits/traits/conditional.h>
#include <c++/bits/traits/declval.h>
#include <c++/bits/traits/is_constructible.h>
#endif /* __USE_ISOCXX11 */
#ifdef __USE_ISOCXX14
#include <c++/bits/integer_sequence.h>
#endif /* __USE_ISOCXX14 */
#ifdef __USE_ISOCXX17
#include <c++/bits/traits/add_cv.h>
#endif /* __USE_ISOCXX17 */
#include <c++/bits/pair.h>
#include <c++/bits/tuple.h>

__CXXDECL_BEGIN
__NAMESPACE_STD_BEGIN

namespace rel_ops {
template<class __T> __CXX_CLASSMEMBER bool __LIBCCALL
operator!=(__T const &__lhs, __T const &__rhs) __CXX_NOEXCEPT_IFNX((bool)!(__lhs == __rhs)) {
	return !(__lhs == __rhs);
}

template<class __T> __CXX_CLASSMEMBER bool __LIBCCALL
operator>(__T const &__lhs, __T const &__rhs) __CXX_NOEXCEPT_IFNX((bool)(__rhs < __lhs)) {
	return __rhs < __lhs;
}

template<class __T> __CXX_CLASSMEMBER bool __LIBCCALL
operator<=(__T const &__lhs, __T const &__rhs) __CXX_NOEXCEPT_IFNX((bool)!(__rhs < __lhs)) {
	return !(__rhs < __lhs);
}

template<class __T> __CXX_CLASSMEMBER bool __LIBCCALL
operator>=(__T const &__lhs, __T const &__rhs) __CXX_NOEXCEPT_IFNX((bool)!(__lhs < __rhs)) {
	return !(__lhs < __rhs);
}

} /* namespace rel_ops */

#ifdef __USE_ISOCXX11
#ifdef __COMPILER_HAVE_CXX_RVALUE_REFERENCE
template<class __T> __CXX14_CONSTEXPR
typename conditional<__NAMESPACE_INT_SYM __and_<is_copy_constructible<__T>,
                                                __NAMESPACE_INT_SYM __not_<is_nothrow_move_constructible<__T> > >::value,
                     __T const &, __T &&>::type
move_if_noexcept(__T &__self) __CXX_NOEXCEPT {
	return move(__self);
}
#endif /* __COMPILER_HAVE_CXX_RVALUE_REFERENCE */
#endif /* __USE_ISOCXX11 */

#ifdef __USE_ISOCXX14
#define __cpp_lib_exchange_function 201304
template<class __T, class __U = __T>
__CXX_FORCEINLINE __T __LIBCCALL
exchange(__T &__obj, __U &&__new_val) {
	__T __old_val(move(__obj));
	__obj.operator=(forward<__U>(__new_val));
	return __old_val;
}
#endif /* __USE_ISOCXX14 */

#ifdef __USE_ISOCXX17
template<class __T>
__CXX_FORCEINLINE __CXX11_CONSTEXPR
typename add_const<__T>::type &__LIBCCALL
as_const(__T &__self) __CXX_NOEXCEPT {
	return __self;
}
#endif /* __USE_ISOCXX14 */

#ifdef __USE_ISOCXX17
struct in_place_t {
	explicit __CXX_DEFAULT_CTOR(in_place_t);
};

static __CXX11_CONSTEXPR in_place_t in_place = in_place_t();

struct in_place_type_t {
	explicit __CXX_DEFAULT_CTOR(in_place_type_t);
};

static __CXX11_CONSTEXPR in_place_type_t in_place_type {};

#ifdef __COMPILER_HAVE_CXX_TEMPLATE_CONSTEXPR
template<__SIZE_TYPE__ __I> struct in_place_index_t { explicit __CXX_DEFAULT_CTOR(in_place_index_t); };
template<__SIZE_TYPE__ __I> static __CXX11_CONSTEXPR in_place_index_t<__I> in_place_index {};
#endif /* __COMPILER_HAVE_CXX_TEMPLATE_CONSTEXPR */
#endif /* __USE_ISOCXX17 */

__NAMESPACE_STD_END
__CXXDECL_END

#endif /* !_CXX_UTILITY */
