CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
109 lines
2.9 KiB
C++
109 lines
2.9 KiB
C++
// Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
#include <concepts>
|
|
#include <deque>
|
|
#include <ranges>
|
|
#include <set>
|
|
#include <string>
|
|
#include <type_traits>
|
|
#include <vector>
|
|
|
|
namespace rocRoller
|
|
{
|
|
template <typename T, typename... U>
|
|
concept CIsAnyOf = (std::same_as<T, U> || ...);
|
|
|
|
static_assert(CIsAnyOf<int, int, float>);
|
|
static_assert(CIsAnyOf<std::string, int, std::string>);
|
|
static_assert(!CIsAnyOf<std::string, int, float>);
|
|
|
|
// clang-format off
|
|
template <typename T>
|
|
concept CHasToStringMember = requires(T const& x)
|
|
{
|
|
!std::convertible_to<std::string, T>;
|
|
|
|
{ x.toString() } -> std::convertible_to<std::string>;
|
|
};
|
|
|
|
template <typename T>
|
|
concept CHasToString = requires(T const& x)
|
|
{
|
|
!std::convertible_to<std::string, T>;
|
|
|
|
{ toString(x) } -> std::convertible_to<std::string>;
|
|
};
|
|
|
|
/**
|
|
* Matches enumerations that are scoped, that have a Count member, and that
|
|
* can be converted to string with toString().
|
|
*/
|
|
template <typename T>
|
|
concept CCountedEnum = requires()
|
|
{
|
|
requires std::regular<T>;
|
|
requires CHasToString<T>;
|
|
|
|
{ T::Count } -> std::convertible_to<T>;
|
|
|
|
{
|
|
static_cast<std::underlying_type_t<T>>(T::Count)
|
|
} -> std::convertible_to<std::underlying_type_t<T>>;
|
|
|
|
|
|
};
|
|
|
|
template <typename Range, typename Of>
|
|
concept CForwardRangeOf = requires()
|
|
{
|
|
requires std::ranges::forward_range<Range>;
|
|
requires std::convertible_to<std::ranges::range_value_t<Range>, Of>;
|
|
};
|
|
|
|
template <typename Range, typename Of>
|
|
concept CInputRangeOf = requires()
|
|
{
|
|
requires std::ranges::input_range<std::remove_reference_t<Range>>;
|
|
requires std::convertible_to<std::ranges::range_value_t<std::remove_reference_t<Range>>, Of>;
|
|
};
|
|
|
|
template <typename T>
|
|
concept CHasName = requires(T const& obj)
|
|
{
|
|
{ name(obj) } -> std::convertible_to<std::string>;
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
static_assert(CForwardRangeOf<std::vector<int>, int>);
|
|
static_assert(CForwardRangeOf<std::vector<short>, int>);
|
|
static_assert(CForwardRangeOf<std::vector<float>, int>);
|
|
static_assert(CForwardRangeOf<std::deque<int>, int>);
|
|
static_assert(CForwardRangeOf<std::set<int>, int>);
|
|
static_assert(!CForwardRangeOf<std::set<std::string>, int>);
|
|
static_assert(!CForwardRangeOf<int, int>);
|
|
|
|
template <typename T>
|
|
concept CPointer = requires()
|
|
{
|
|
requires std::is_pointer_v<T>;
|
|
};
|
|
|
|
static_assert(!CPointer<int>);
|
|
static_assert(CPointer<int*>);
|
|
static_assert(CPointer<int const*>);
|
|
static_assert(CPointer<char const*>);
|
|
static_assert(CPointer<char*>);
|
|
|
|
template <typename T>
|
|
concept CHashable = requires(T a)
|
|
{
|
|
{
|
|
std::hash<T>{}(a)
|
|
} -> std::convertible_to<std::size_t>;
|
|
};
|
|
}
|