//@HEADER // ************************************************************************ // // Kokkos v. 4.0 // Copyright (2022) National Technology & Engineering // Solutions of Sandia, LLC (NTESS). // // Under the terms of Contract DE-NA0003525 with NTESS, // the U.S. Government retains certain rights in this software. // // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. // See https://kokkos.org/LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //@HEADER #ifndef KOKKOS_CORE_IMPL_UTILITIES_HPP #define KOKKOS_CORE_IMPL_UTILITIES_HPP #include #include #include #include // in-order comma operator fold emulation #include // integer_sequence and friends //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- namespace Kokkos { namespace Impl { // same as std::integral_constant but with __host__ __device__ annotations on // the implicit conversion function and the call operator template struct integral_constant { using value_type = T; using type = integral_constant; static constexpr T value = v; KOKKOS_FUNCTION constexpr operator value_type() const noexcept { return value; } KOKKOS_FUNCTION constexpr value_type operator()() const noexcept { return value; } }; //============================================================================== template struct always_true : std::true_type {}; // type-dependent expression that is always false intended for use in // static_assert to check "we should never get there" template struct always_false : std::false_type {}; //============================================================================== #if defined(__cpp_lib_type_identity) // since C++20 using std::type_identity; using std::type_identity_t; #else template struct type_identity { using type = T; }; template using type_identity_t = typename type_identity::type; #endif #if defined(__cpp_lib_remove_cvref) // since C++20 using std::remove_cvref; using std::remove_cvref_t; #else template struct remove_cvref { using type = std::remove_cv_t>; }; template using remove_cvref_t = typename remove_cvref::type; #endif // same as C++23 std::to_underlying but with __host__ __device__ annotations template KOKKOS_FUNCTION constexpr std::underlying_type_t to_underlying( E e) noexcept { return static_cast>(e); } #if defined(__cpp_lib_is_scoped_enum) // since C++23 using std::is_scoped_enum; using std::is_scoped_enum_v; #else template > struct is_scoped_enum_impl : std::false_type {}; template struct is_scoped_enum_impl : std::bool_constant>> { }; template struct is_scoped_enum : is_scoped_enum_impl::type {}; template inline constexpr bool is_scoped_enum_v = is_scoped_enum::value; #endif //============================================================================== // {{{1 template class Template, class Enable = void> struct is_specialization_of : std::false_type {}; template