forked from abseil/abseil-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutility.h
More file actions
127 lines (101 loc) · 4.08 KB
/
Copy pathutility.h
File metadata and controls
127 lines (101 loc) · 4.08 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright 2017 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef ABSL_UTILITY_UTILITY_H_
#define ABSL_UTILITY_UTILITY_H_
#include <cstddef>
#include <cstdlib>
#include <tuple>
#include <type_traits>
#include <utility>
#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/macros.h"
// TODO(b/290784225): Include what you use cleanup required.
#include "absl/meta/type_traits.h"
// TODO(b/509512528): Deprecate the C++14/C++17 symbols publicly, in all files.
namespace absl {
ABSL_NAMESPACE_BEGIN
// Historical note: Abseil once provided implementations of these
// abstractions for platforms that had not yet provided them. Those
// platforms are no longer supported. New code should simply use the
// the ones from std directly.
using std::apply;
template <class T1, class T2 = T1>
ABSL_DEPRECATE_AND_INLINE()
constexpr T1 exchange(T1& obj, T2&& new_value) noexcept(
noexcept(std::exchange(std::declval<T1&>(), std::declval<T2>()))) {
return std::exchange(obj, std::forward<T2>(new_value));
}
template <class T>
[[deprecated("Use std::forward instead.")]] [[nodiscard]] constexpr T&& forward(
std::remove_reference_t<T>& arg ABSL_ATTRIBUTE_LIFETIME_BOUND) noexcept {
// NOLINTNEXTLINE: Avoid warnings about T not being the spelled type of arg.
return std::forward<T>(arg);
}
template <class T>
[[deprecated("Use std::forward instead.")]] [[nodiscard]] constexpr T&& forward(
std::remove_reference_t<T>&& arg ABSL_ATTRIBUTE_LIFETIME_BOUND) noexcept {
// NOLINTNEXTLINE: Avoid warnings about T not being the spelled type of arg.
return std::forward<T>(arg);
}
inline constexpr const std::in_place_t& in_place ABSL_DEPRECATE_AND_INLINE() =
std::in_place;
template <size_t I>
inline constexpr const std::in_place_index_t<I>& in_place_index
ABSL_DEPRECATE_AND_INLINE() = std::in_place_index<I>;
template <size_t I>
using in_place_index_t ABSL_DEPRECATE_AND_INLINE() = std::in_place_index_t<I>;
using in_place_t ABSL_DEPRECATE_AND_INLINE() = std::in_place_t;
template <class T>
inline constexpr const std::in_place_type_t<T>& in_place_type
ABSL_DEPRECATE_AND_INLINE() = std::in_place_type<T>;
template <class T>
using in_place_type_t ABSL_DEPRECATE_AND_INLINE() = std::in_place_type_t<T>;
template <size_t... I>
using index_sequence ABSL_DEPRECATE_AND_INLINE() = std::index_sequence<I...>;
template <class T, T... I>
using integer_sequence ABSL_DEPRECATE_AND_INLINE() =
std::integer_sequence<T, I...>;
template <class... T>
using index_sequence_for ABSL_DEPRECATE_AND_INLINE() =
std::index_sequence_for<T...>;
template <class T, class Tuple>
ABSL_DEPRECATE_AND_INLINE()
[[nodiscard]] constexpr decltype(std::make_from_tuple<T>(std::declval<Tuple>()))
make_from_tuple(Tuple&& arg) noexcept(
noexcept(std::make_from_tuple<T>(std::declval<Tuple>()))) {
return std::make_from_tuple<T>(std::forward<Tuple>(arg));
}
template <size_t N>
using make_index_sequence ABSL_DEPRECATE_AND_INLINE() =
std::make_index_sequence<N>;
template <class T, T N>
using make_integer_sequence ABSL_DEPRECATE_AND_INLINE() =
std::make_integer_sequence<T, N>;
using std::move;
#if ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
// Backfill for std::nontype_t. An instance of this class can be provided as a
// disambiguation tag to `absl::function_ref` to pass the address of a known
// callable at compile time.
// Requires C++20 due to `auto` template parameter.
template <auto>
struct nontype_t {
explicit nontype_t() = default;
};
template <auto V>
constexpr nontype_t<V> nontype{};
#endif
ABSL_NAMESPACE_END
} // namespace absl
#endif // ABSL_UTILITY_UTILITY_H_