//===----------------------------------------------------------------------===//
//
// Part of libcu++, the C++ Standard Library for your entire system,
// under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//

#ifndef _CUDA_STD___TYPE_TRAITS_OPERATIONS_H
#define _CUDA_STD___TYPE_TRAITS_OPERATIONS_H

#include <cuda/std/detail/__config>

#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
#  pragma GCC system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
#  pragma clang system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
#  pragma system_header
#endif // no system header

#include <cuda/std/__concepts/concept_macros.h>
#include <cuda/std/__cstddef/types.h>

#include <cuda/std/__cccl/prologue.h>

_CCCL_BEGIN_NAMESPACE_CUDA_STD

// Use a dedicated template parameter name (`_OpT`) rather than the library-wide
// `_Tp` so that NVRTC (which lacks `__COUNTER__` and falls back to
// `<param>##__LINE__` to name the detail class generated by
// `_CCCL_REQUIRES_EXPR`) cannot produce a collision with any `_Tp`-based
// concept declared at the same line in another concepts/type-traits header.

// unary operator constraints

template <typename _OpT>
_CCCL_CONCEPT __has_pre_increment = _CCCL_REQUIRES_EXPR((_OpT), _OpT& __t)((++__t));

template <typename _OpT>
_CCCL_CONCEPT __has_post_increment = _CCCL_REQUIRES_EXPR((_OpT), _OpT __t)((__t++));

template <typename _OpT>
_CCCL_CONCEPT __has_pre_decrement = _CCCL_REQUIRES_EXPR((_OpT), _OpT& __t)((--__t));

template <typename _OpT>
_CCCL_CONCEPT __has_post_decrement = _CCCL_REQUIRES_EXPR((_OpT), _OpT __t)((__t--));

template <typename _OpT>
_CCCL_CONCEPT __has_negate = _CCCL_REQUIRES_EXPR((_OpT), const _OpT __t)((!__t));

template <typename _OpT>
_CCCL_CONCEPT __has_bitwise_not = _CCCL_REQUIRES_EXPR((_OpT), const _OpT __t)((~__t));

template <typename _OpT>
_CCCL_CONCEPT __has_unary_plus = _CCCL_REQUIRES_EXPR((_OpT), const _OpT __t)((+__t));

template <typename _OpT>
_CCCL_CONCEPT __has_unary_minus = _CCCL_REQUIRES_EXPR((_OpT), const _OpT __t)((-__t));

// binary operator constraints

template <typename _OpT>
_CCCL_CONCEPT __has_binary_plus = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a + __b));

template <typename _OpT>
_CCCL_CONCEPT __has_binary_minus = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a - __b));

template <typename _OpT>
_CCCL_CONCEPT __has_multiplies = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a * __b));

template <typename _OpT>
_CCCL_CONCEPT __has_divides = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a / __b));

template <typename _OpT>
_CCCL_CONCEPT __has_modulo = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a % __b));

template <typename _OpT>
_CCCL_CONCEPT __has_bitwise_and = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a & __b));

template <typename _OpT>
_CCCL_CONCEPT __has_bitwise_or = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a | __b));

template <typename _OpT>
_CCCL_CONCEPT __has_bitwise_xor = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a ^ __b));

template <typename _OpT>
_CCCL_CONCEPT __has_shift_left = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a << __b));

template <typename _OpT>
_CCCL_CONCEPT __has_shift_right = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a >> __b));

template <typename _OpT>
_CCCL_CONCEPT __has_shift_left_size = _CCCL_REQUIRES_EXPR((_OpT), _OpT __t)((__t << ptrdiff_t{}));

template <typename _OpT>
_CCCL_CONCEPT __has_shift_right_size = _CCCL_REQUIRES_EXPR((_OpT), _OpT __t)((__t >> ptrdiff_t{}));

// comparison operator constraints

template <typename _OpT>
_CCCL_CONCEPT __has_equal_to = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a == __b));

template <typename _OpT>
_CCCL_CONCEPT __has_not_equal_to = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a != __b));

template <typename _OpT>
_CCCL_CONCEPT __has_greater_equal = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a >= __b));

template <typename _OpT>
_CCCL_CONCEPT __has_less_equal = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a <= __b));

template <typename _OpT>
_CCCL_CONCEPT __has_greater = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a > __b));

template <typename _OpT>
_CCCL_CONCEPT __has_less = _CCCL_REQUIRES_EXPR((_OpT), _OpT __a, _OpT __b)((__a < __b));

_CCCL_END_NAMESPACE_CUDA_STD

#include <cuda/std/__cccl/epilogue.h>

#endif // _CUDA_STD___TYPE_TRAITS_OPERATIONS_H
