forked from IngoRoessner/carGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.h
40 lines (33 loc) · 1.12 KB
/
configuration.h
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
37
38
39
40
#ifndef CONFIGURATION_H_INCLUDED
#define CONFIGURATION_H_INCLUDED
template<template<class> class... Mixins>
class Config{
public:
template<template<class> class part>
static constexpr bool containsPart(){
return partTemplateBaseOf<part, Mixins...>();
}
template<class part>
static constexpr bool containsPart(){
return partClassBaseOf<part, Mixins...>();
}
private:
struct Dummy{};
template<template<class> class T1>
static constexpr bool partTemplateBaseOf(){
return false;
}
template<template<class> class T1, template<class> class T2, template<class> class... Tx>
static constexpr bool partTemplateBaseOf(){
return is_base_of<T1<Dummy>, T2<Dummy>>::value ? true : partTemplateBaseOf<T1, Tx...>();
}
template<typename T1>
static constexpr bool partClassBaseOf(){
return false;
}
template<typename T1, template<class> class T2, template<class> class... Tx>
static constexpr bool partClassBaseOf(){
return is_base_of<T1, T2<Dummy>>::value ? true : partClassBaseOf<T1, Tx...>();
}
};
#endif // CONFIGURATION_H_INCLUDED