MySQL 8.3.0
Source Code Documentation
type_traits.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2019, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef MYSQL_HARNESS_STDX_TYPE_TRAITS_H_
26#define MYSQL_HARNESS_STDX_TYPE_TRAITS_H_
27
28#include <type_traits>
29
30namespace stdx {
31
32// from http://wg21.link/P0463 (part of C++20)
33enum class endian {
34#ifdef _WIN32
35 little = 0,
36 big = 1,
38#else
39 little = __ORDER_LITTLE_ENDIAN__,
40 big = __ORDER_BIG_ENDIAN__,
41 native = __BYTE_ORDER__,
42#endif
43};
44
45// from C++23
46// wg21.link/P1048
47
48// all non-enums are also non-scoped-enums
49template <class T, bool B = std::is_enum_v<T>>
50struct __is_scoped_enum_helper : std::false_type {};
51
52// scoped enums are enum's that can't be automatically be converted into its
53// underlying type.
54template <class T>
56 : std::bool_constant<!std::is_convertible_v<T, std::underlying_type_t<T>>> {
57};
58
59template <class T>
61
62template <class E>
64
65// C++20
66template <class T>
68 using type = std::remove_cv_t<std::remove_reference_t<T>>;
69};
70
71template <class T>
73
74template <class T>
76 using type = T;
77};
78
79template <class T>
81
82} // namespace stdx
83
84#endif
Definition: bit.h:33
constexpr bool is_scoped_enum_v
Definition: type_traits.h:63
endian
Definition: type_traits.h:33
typename type_identity< T >::type type_identity_t
Definition: type_traits.h:80
typename remove_cvref< T >::type remove_cvref_t
Definition: type_traits.h:72
Definition: type_traits.h:50
Definition: type_traits.h:60
Definition: type_traits.h:67
std::remove_cv_t< std::remove_reference_t< T > > type
Definition: type_traits.h:68
Definition: type_traits.h:75
T type
Definition: type_traits.h:76