summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Dino Radakovic <dinor@google.com>2023-12-11 12:28:21 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2023-12-11 12:29:26 -0800
commit8843e8e2bd7074e2ae84fa3f11eeef11683dee1b (patch)
tree58758a3c051af7a1f1129f071dc621a28201be6b /absl
parent55621d1af55be7bf9a2c8e5dcef4368d9a6d4e51 (diff)
`absl/utility`: Delete C++11-compatible `integer_sequence` and friends
Abseil does not support C++11 anymore: https://github.com/google/oss-policies-info/blob/b842c39db88e6569dfe2cf98be434b03507cb503/foundational-cxx-support-matrix.md NOTE: This is a breaking change because `std::integer_sequence<T>` requires `std::is_integral_v<T>`, but `absl::integer_sequence<T>` does not. Unit tests will be deleted in a follow-up. PiperOrigin-RevId: 589908215 Change-Id: I57a81e4451840304d5fba60bef286e81e024af9c
Diffstat (limited to 'absl')
-rw-r--r--absl/utility/utility.h104
1 files changed, 11 insertions, 93 deletions
diff --git a/absl/utility/utility.h b/absl/utility/utility.h
index bf923220..fc0d1f65 100644
--- a/absl/utility/utility.h
+++ b/absl/utility/utility.h
@@ -12,17 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
-// This header file contains C++11 versions of standard <utility> header
-// abstractions available within C++14 and C++17, and are designed to be drop-in
+// This header file contains C++14 versions of standard <utility> header
+// abstractions available within C++17, and are designed to be drop-in
// replacement for code compliant with C++14 and C++17.
//
// The following abstractions are defined:
//
-// * integer_sequence<T, Ints...> == std::integer_sequence<T, Ints...>
-// * index_sequence<Ints...> == std::index_sequence<Ints...>
-// * make_integer_sequence<T, N> == std::make_integer_sequence<T, N>
-// * make_index_sequence<N> == std::make_index_sequence<N>
-// * index_sequence_for<Ts...> == std::index_sequence_for<Ts...>
// * apply<Functor, Tuple> == std::apply<Functor, Tuple>
// * exchange<T> == std::exchange<T>
// * make_from_tuple<T> == std::make_from_tuple<T>
@@ -33,7 +28,6 @@
//
// References:
//
-// https://en.cppreference.com/w/cpp/utility/integer_sequence
// https://en.cppreference.com/w/cpp/utility/apply
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3658.html
@@ -53,68 +47,18 @@
namespace absl {
ABSL_NAMESPACE_BEGIN
-// integer_sequence
-//
-// Class template representing a compile-time integer sequence. An instantiation
-// of `integer_sequence<T, Ints...>` has a sequence of integers encoded in its
-// type through its template arguments (which is a common need when
-// working with C++11 variadic templates). `absl::integer_sequence` is designed
-// to be a drop-in replacement for C++14's `std::integer_sequence`.
-//
-// Example:
-//
-// template< class T, T... Ints >
-// void user_function(integer_sequence<T, Ints...>);
-//
-// int main()
-// {
-// // user_function's `T` will be deduced to `int` and `Ints...`
-// // will be deduced to `0, 1, 2, 3, 4`.
-// user_function(make_integer_sequence<int, 5>());
-// }
-template <typename T, T... Ints>
-struct integer_sequence {
- using value_type = T;
- static constexpr size_t size() noexcept { return sizeof...(Ints); }
-};
-
-// index_sequence
-//
-// A helper template for an `integer_sequence` of `size_t`,
-// `absl::index_sequence` is designed to be a drop-in replacement for C++14's
-// `std::index_sequence`.
-template <size_t... Ints>
-using index_sequence = integer_sequence<size_t, Ints...>;
+// 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::index_sequence;
+using std::index_sequence_for;
+using std::integer_sequence;
+using std::make_index_sequence;
+using std::make_integer_sequence;
namespace utility_internal {
-template <typename Seq, size_t SeqSize, size_t Rem>
-struct Extend;
-
-// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency.
-template <typename T, T... Ints, size_t SeqSize>
-struct Extend<integer_sequence<T, Ints...>, SeqSize, 0> {
- using type = integer_sequence<T, Ints..., (Ints + SeqSize)...>;
-};
-
-template <typename T, T... Ints, size_t SeqSize>
-struct Extend<integer_sequence<T, Ints...>, SeqSize, 1> {
- using type = integer_sequence<T, Ints..., (Ints + SeqSize)..., 2 * SeqSize>;
-};
-
-// Recursion helper for 'make_integer_sequence<T, N>'.
-// 'Gen<T, N>::type' is an alias for 'integer_sequence<T, 0, 1, ... N-1>'.
-template <typename T, size_t N>
-struct Gen {
- using type =
- typename Extend<typename Gen<T, N / 2>::type, N / 2, N % 2>::type;
-};
-
-template <typename T>
-struct Gen<T, 0> {
- using type = integer_sequence<T>;
-};
-
template <typename T>
struct InPlaceTypeTag {
explicit InPlaceTypeTag() = delete;
@@ -131,32 +75,6 @@ struct InPlaceIndexTag {
} // namespace utility_internal
-// Compile-time sequences of integers
-
-// make_integer_sequence
-//
-// This template alias is equivalent to
-// `integer_sequence<int, 0, 1, ..., N-1>`, and is designed to be a drop-in
-// replacement for C++14's `std::make_integer_sequence`.
-template <typename T, T N>
-using make_integer_sequence = typename utility_internal::Gen<T, N>::type;
-
-// make_index_sequence
-//
-// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`,
-// and is designed to be a drop-in replacement for C++14's
-// `std::make_index_sequence`.
-template <size_t N>
-using make_index_sequence = make_integer_sequence<size_t, N>;
-
-// index_sequence_for
-//
-// Converts a typename pack into an index sequence of the same length, and
-// is designed to be a drop-in replacement for C++14's
-// `std::index_sequence_for()`
-template <typename... Ts>
-using index_sequence_for = make_index_sequence<sizeof...(Ts)>;
-
// Tag types
#ifdef ABSL_USES_STD_OPTIONAL