-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTypeTraits.h
More file actions
36 lines (23 loc) · 901 Bytes
/
TypeTraits.h
File metadata and controls
36 lines (23 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include <type_traits>
template<template<auto...> class Container, class ToTest>
constexpr bool is_instance = false;
template<template<auto...> class Container, auto... Ts>
constexpr bool is_instance<Container, Container<Ts...>> = true;
template<template<auto...> class Container, class... ToTest>
constexpr bool are_instances = (is_instance<Container, ToTest> && ...);
template<unsigned int n, auto... Ts>
requires (sizeof...(Ts) > n)
struct ExtractNthArg {
template<int i, auto first, auto... rest>
struct Step {
static constexpr auto value = Step<i + 1, rest...>::value;
};
template<auto first, auto... rest>
struct Step<n, first, rest...> {
static constexpr auto value = first;
};
static constexpr auto value = Step<0, Ts...>::value;
};
template<auto... Ts>
static constexpr auto extract_nth_arg = ExtractNthArg<Ts...>::value;