-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Expand file tree
/
Copy path2.26.bool.metafunctions.cpp
More file actions
25 lines (22 loc) 路 792 Bytes
/
Copy path2.26.bool.metafunctions.cpp
File metadata and controls
25 lines (22 loc) 路 792 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
//
// 2.26.bool.metafunctions.cpp
// chapter 2 language usability
// modern cpp tutorial
//
// created by changkun at changkun.de
// https://github.com/changkun/modern-cpp-tutorial
//
#include <iostream>
#include <type_traits>
// C++17 logical metafunctions compose other type traits.
template <typename T>
constexpr bool is_signed_integral =
std::conjunction_v<std::is_integral<T>, std::is_signed<T>>;
int main() {
static_assert(is_signed_integral<int>);
static_assert(!is_signed_integral<unsigned>);
static_assert(std::disjunction_v<std::is_integral<float>,
std::is_floating_point<float>>);
static_assert(std::negation_v<std::is_floating_point<int>>);
std::cout << "all logical metafunction assertions passed" << std::endl;
}