/
type_traits.d
50 lines (43 loc) · 1.03 KB
/
type_traits.d
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
41
42
43
44
45
46
47
48
49
50
/**
* D header file for interaction with C++ std::type_traits.
*
* Copyright: Copyright Digital Mars 2018.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Manu Evans
* Source: $(DRUNTIMESRC core/stdcpp/type_traits.d)
*/
module core.stdcpp.type_traits;
extern(C++, "std"):
///
struct integral_constant(T, T Val)
{
///
enum T value = Val;
///
alias value_type = T;
///
alias type = typeof(this);
}
///
alias bool_constant(bool b) = integral_constant!(bool, b);
// Useful for dealing with enable_if constraints.
///
alias true_type = bool_constant!true;
///
alias false_type = bool_constant!false;
///
struct is_empty(T)
{
static if (is(T == struct))
private enum __is_empty = T.tupleof.length == 0;
else
private enum __is_empty = false;
///
enum bool value = __is_empty;
///
alias value_type = bool;
///
alias type = integral_constant!(bool, value);
}