MySQL 8.0.39
Source Code Documentation
type_traits.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2019, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQL_HARNESS_STDX_TYPE_TRAITS_H_
27#define MYSQL_HARNESS_STDX_TYPE_TRAITS_H_
28
29#include <type_traits>
30
31namespace stdx {
32
33// from http://wg21.link/P0463 (part of C++20)
34enum class endian {
35#ifdef _WIN32
36 little = 0,
37 big = 1,
39#else
40 little = __ORDER_LITTLE_ENDIAN__,
41 big = __ORDER_BIG_ENDIAN__,
42 native = __BYTE_ORDER__,
43#endif
44};
45
46// from C++23
47// wg21.link/P1048
48
49// all non-enums are also non-scoped-enums
50template <class T, bool B = std::is_enum_v<T>>
51struct __is_scoped_enum_helper : std::false_type {};
52
53// scoped enums are enum's that can't be automatically be converted into its
54// underlying type.
55template <class T>
57 : std::bool_constant<!std::is_convertible_v<T, std::underlying_type_t<T>>> {
58};
59
60template <class T>
62
63template <class E>
65
66// C++20
67template <class T>
69 using type = std::remove_cv_t<std::remove_reference_t<T>>;
70};
71
72template <class T>
74
75template <class T>
77 using type = T;
78};
79
80template <class T>
82
83} // namespace stdx
84
85#endif
Definition: bit.h:34
constexpr bool is_scoped_enum_v
Definition: type_traits.h:64
endian
Definition: type_traits.h:34
typename type_identity< T >::type type_identity_t
Definition: type_traits.h:81
typename remove_cvref< T >::type remove_cvref_t
Definition: type_traits.h:73
Definition: type_traits.h:51
Definition: type_traits.h:61
Definition: type_traits.h:68
std::remove_cv_t< std::remove_reference_t< T > > type
Definition: type_traits.h:69
Definition: type_traits.h:76
T type
Definition: type_traits.h:77