// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Copyright (C) Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// This file incorporates work covered by the following copyright and permission
// notice:
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//

#ifndef _ONEDPL_FUNCTIONAL
#define _ONEDPL_FUNCTIONAL

#include "oneapi/dpl/internal/common_config.h"
#include <functional>

#include "oneapi/dpl/utility"

namespace oneapi
{
namespace dpl
{
using ::std::bind;
using ::std::bit_and;
using ::std::bit_or;
using ::std::bit_xor;
using ::std::cref;
using ::std::divides;
using ::std::equal_to;
using ::std::greater;
using ::std::greater_equal;
using ::std::less;
using ::std::less_equal;
using ::std::logical_and;
using ::std::logical_not;
using ::std::logical_or;
using ::std::minus;
using ::std::modulus;
using ::std::multiplies;
using ::std::negate;
using ::std::not_equal_to;
using ::std::plus;
using ::std::ref;
using ::std::reference_wrapper;
#if _ONEDPL___cplusplus < 202002L
using ::std::binary_negate; // Deprecated in C++17, removed in C++20
using ::std::not1;          // Deprecated in C++17, removed in C++20
using ::std::not2;          // Deprecated in C++17, removed in C++20
using ::std::unary_negate;  // Deprecated in C++17, removed in C++20
#endif                      // _ONEDPL___cplusplus < 202002L
using ::std::bit_not;

struct identity
{
    using is_transparent = void;

    template <typename _T>
    constexpr _T&&
    operator()(_T&& t) const noexcept
    {
        return ::std::forward<_T>(t);
    }
};

template <typename _T>
struct maximum
{
    constexpr const _T&
    operator()(const _T& a, const _T& b) const
    {
        return ::std::greater<_T>()(a, b) ? a : b;
    }
};

template <typename _T>
struct minimum
{
    constexpr const _T&
    operator()(const _T& a, const _T& b) const
    {
        return ::std::less<_T>()(a, b) ? a : b;
    }
};
} // end namespace dpl
} // end namespace oneapi

namespace dpl = oneapi::dpl;

#endif // _ONEDPL_FUNCTIONAL
