File: type_traits

package info (click to toggle)
cmake 4.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 152,344 kB
  • sloc: ansic: 403,894; cpp: 303,807; sh: 4,097; python: 3,582; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 108; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (89 lines) | stat: -rw-r--r-- 1,996 bytes parent folder | download | duplicates (3)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// -*-c++-*-
// vim: set ft=cpp:

/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file LICENSE.rst or https://cmake.org/licensing for details.  */
#pragma once

#include <type_traits> // IWYU pragma: export

namespace cm {

#if __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)

// Miscellaneous transformations
template <bool B, typename T = void>
using enable_if_t = std::enable_if_t<B, T>;

#else

// Miscellaneous transformations
template <bool B, typename T = void>
using enable_if_t = typename std::enable_if<B, T>::type;

#endif

#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)

// Helper classes
using std::bool_constant;

// Miscellaneous transformations
using std::invoke_result;
using std::invoke_result_t;

using std::void_t;

#else

// Helper classes
template <bool B>
using bool_constant = std::integral_constant<bool, B>;

// Miscellaneous transformations
template <typename F, typename... ArgTypes>
using invoke_result = std::result_of<F(ArgTypes...)>;

template <class F, typename... ArgTypes>
using invoke_result_t = typename invoke_result<F, ArgTypes...>::type;

template <typename... ArgTypes>
struct make_void
{
  typedef void type;
};
template <typename... ArgTypes>
using void_t = typename make_void<ArgTypes...>::type;

#endif

#if (__cplusplus >= 202302L ||                                                \
     (defined(_MSVC_LANG) && _MSVC_LANG >= 202302L)) &&                       \
  __cpp_lib_is_scoped_enum == 202011L

using std::is_scoped_enum;

#else

namespace internals {
template <typename T, bool = std::is_enum<T>::value>
struct is_scoped_enum_helper : std::false_type
{
};

template <typename T>
struct is_scoped_enum_helper<T, true>
  : public cm::bool_constant<
      !std::is_convertible<T, typename std::underlying_type<T>::type>::value>
{
};
}

template <typename T>
struct is_scoped_enum : public internals::is_scoped_enum_helper<T>
{
};

#endif

} // namespace cm