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
112 lines
3.3 KiB
C++
112 lines
3.3 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the libcu++ Project, 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// metafunction header that provides some vocabulary for manipulating type packs
|
|
// exports:
|
|
// rotl<T...>
|
|
// for_n<Count, T, Fn>
|
|
// bind_last<Fn<...>, B>
|
|
// append<List, Tx...>
|
|
// append_n<Count, List, T>
|
|
|
|
#ifndef HETEROGENEOUS_META_H
|
|
#define HETEROGENEOUS_META_H
|
|
|
|
template <typename... Tx>
|
|
struct type_list
|
|
{};
|
|
|
|
// Rotates the typelist by removing the head and moving it to the tail
|
|
template <typename... Tx>
|
|
struct rotl_impl
|
|
{
|
|
// Empty or 1 element case
|
|
using type = type_list<Tx...>;
|
|
};
|
|
template <typename T, typename... Tx>
|
|
struct rotl_impl<T, Tx...>
|
|
{
|
|
using type = type_list<Tx..., T>;
|
|
};
|
|
template <typename... Tx>
|
|
struct rotl_impl<type_list<Tx...>>
|
|
{
|
|
using type = typename rotl_impl<Tx...>::type;
|
|
};
|
|
|
|
template <typename... Tx>
|
|
using rotl = typename rotl_impl<Tx...>::type;
|
|
|
|
// static_assert(std::is_same<rotl<int, char>, type_list<char,int>>(), "");
|
|
// static_assert(std::is_same<rotl<int, char, short>, type_list<char,short,int>>(), "");
|
|
|
|
template <size_t Idx, typename T, template <typename> class Fn>
|
|
struct for_n_impl
|
|
{
|
|
using type = typename for_n_impl<Idx - 1, Fn<T>, Fn>::type;
|
|
};
|
|
template <typename T, template <typename> class Fn>
|
|
struct for_n_impl<1, T, Fn>
|
|
{
|
|
using type = Fn<T>;
|
|
};
|
|
template <typename T, template <typename> class Fn>
|
|
struct for_n_impl<0, T, Fn>
|
|
{
|
|
using type = T;
|
|
};
|
|
|
|
template <size_t Idx, typename T, template <typename> class Fn>
|
|
using for_n = typename for_n_impl<Idx, T, Fn>::type;
|
|
|
|
// static_assert(std::is_same<for_n<2, type_list<int, char, short>, rotl>, type_list<short, int, char>>(), "");
|
|
// static_assert(std::is_same<for_n<3, type_list<int, char, short>, rotl>, type_list<int, char, short>>(), "");
|
|
|
|
template <template <typename...> class Fn, typename B>
|
|
struct bind_last_impl
|
|
{
|
|
template <typename T>
|
|
struct bound
|
|
{
|
|
using type = Fn<T, B>;
|
|
};
|
|
|
|
template <typename T>
|
|
using type = typename bound<T>::type;
|
|
};
|
|
|
|
template <template <typename...> class Fn, typename B>
|
|
using bind_last = bind_last_impl<Fn, B>;
|
|
|
|
template <typename TypeList, typename... Tx>
|
|
struct append_impl;
|
|
template <typename... Old, typename... New>
|
|
struct append_impl<type_list<Old...>, New...>
|
|
{
|
|
using type = type_list<Old..., New...>;
|
|
};
|
|
template <typename... Old, typename... New>
|
|
struct append_impl<type_list<Old...>, type_list<New...>>
|
|
{
|
|
using type = type_list<Old..., New...>;
|
|
};
|
|
|
|
template <typename TypeList, typename... Tx>
|
|
using append = typename append_impl<TypeList, Tx...>::type;
|
|
|
|
// static_assert(std::is_same<append<type_list<>, int>, type_list<int>>(), "");
|
|
// static_assert(std::is_same<append<type_list<int>, int>, type_list<int,int>>(), "");
|
|
|
|
template <size_t Idx, typename TypeList, typename T>
|
|
using append_n = for_n<Idx, TypeList, bind_last<append, T>::template type>;
|
|
|
|
// static_assert(std::is_same<append_n<3, type_list<char>, int>, type_list<char, int, int, int>>(), "");
|
|
// static_assert(std::is_same<append_n<5, type_list<char>, int>, type_list<char, int, int, int, int, int>>(), "");
|
|
|
|
#endif // HETEROGENEOUS_META_H
|