//@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_DETECTION_IDIOM_HPP #define KOKKOS_DETECTION_IDIOM_HPP #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE #define KOKKOS_IMPL_PUBLIC_INCLUDE #define KOKKOS_IMPL_PUBLIC_INCLUDE_NOTDEFINED_DETECTIONIDIOM #endif #include // FIXME doesn't actually need it if it wasn't // for the header self-containment test #include // NOTE This header implements the detection idiom from Version 2 of the C++ // Extensions for Library Fundamentals, ISO/IEC TS 19568:2017 // I deliberately omitted detected_or which does not fit well with the rest // of the specification. In my opinion, it should be removed from the TS. namespace Kokkos { namespace Impl { // base class for nonesuch to inherit from so it is not an aggregate struct nonesuch_base {}; // primary template handles all types not supporting the archetypal Op template class Op, class... /*Args*/> struct detector { using value_t = std::false_type; using type = Default; }; // specialization recognizes and handles only types supporting Op template class Op, class... Args> struct detector>, Op, Args...> { using value_t = std::true_type; using type = Op; }; } // namespace Impl struct nonesuch : private Impl::nonesuch_base { ~nonesuch() = delete; nonesuch(nonesuch const&) = delete; void operator=(nonesuch const&) = delete; }; template