Skip to content

Instantly share code, notes, and snippets.

@afabri
Created March 11, 2022 06:47
Show Gist options
  • Save afabri/9aa601c5a469e362caa1e65f9c851deb to your computer and use it in GitHub Desktop.
Save afabri/9aa601c5a469e362caa1e65f9c851deb to your computer and use it in GitHub Desktop.
Find a kernel that is not the Dummy_kernel
#include <type_traits>
#include <typeinfo>
#include <iostream>
template <typename T>
struct Dummy
{};
struct Cartesian
{};
struct Point
{};
struct Number
{};
template <typename T>
struct Kernel_traits
{
typedef Dummy<T> type;
};
template <>
struct Kernel_traits<Point>
{
typedef Cartesian type;
};
template <typename... T>
struct Kernel_traits_N {
typedef int type;
};
template<
typename T,
typename... Rest
>
struct Kernel_traits_N<T, Rest...> {
typedef typename std::conditional<std::is_same<Dummy<T>, typename Kernel_traits<T>::type>::value,
typename Kernel_traits_N<Rest...>::type,
typename Kernel_traits<T>::type>::type type;
};
int main()
{
typedef Kernel_traits_N<char, Point, Number>::type T;
std::cout << typeid(T).name() << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment