mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-13 20:12:26 +00:00
24 lines
437 B
C++
24 lines
437 B
C++
// https://cirosantilli.com/linux-kernel-module-cheat#cpp
|
|
|
|
#if __cplusplus >= 201703L
|
|
#include <cassert>
|
|
#include <type_traits>
|
|
|
|
template <class T>
|
|
struct MyClass {
|
|
int myFunc() {
|
|
if constexpr(std::is_integral<T>())
|
|
return 1;
|
|
else
|
|
return 2;
|
|
}
|
|
};
|
|
#endif
|
|
|
|
int main() {
|
|
#if __cplusplus >= 201703L
|
|
assert(MyClass<int>().myFunc() == 1);
|
|
assert(MyClass<float>().myFunc() == 2);
|
|
#endif
|
|
}
|