[libcxx-commits] [libcxx] [libc++] Remove _LIBCPP_AUTO_CAST (PR #66027)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 10 03:08:35 PDT 2024


https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/66027

>From c115c3ca5ac7c9634080e0a4ffcd04f9577c5f79 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Tue, 12 Sep 2023 01:06:25 +0200
Subject: [PATCH] [libc++] Remove _LIBCPP_AUTO_CAST

---
 libcxx/include/CMakeLists.txt        |  1 -
 libcxx/include/__ranges/access.h     | 34 ++++++++++++----------------
 libcxx/include/__ranges/all.h        |  6 ++---
 libcxx/include/__ranges/data.h       |  3 +--
 libcxx/include/__ranges/drop_view.h  | 24 +++++++++-----------
 libcxx/include/__ranges/rbegin.h     | 13 +++++------
 libcxx/include/__ranges/rend.h       | 20 +++++++---------
 libcxx/include/__ranges/size.h       | 13 +++++------
 libcxx/include/__ranges/take_view.h  |  6 ++---
 libcxx/include/__utility/auto_cast.h | 22 ------------------
 libcxx/include/future                |  5 ++--
 libcxx/include/module.modulemap      |  4 ----
 libcxx/include/string                |  3 +--
 libcxx/include/utility               |  1 -
 14 files changed, 53 insertions(+), 102 deletions(-)
 delete mode 100644 libcxx/include/__utility/auto_cast.h

diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index e37c4ac4fddd8c..253056c8c170b4 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -851,7 +851,6 @@ set(files
   __undef_macros
   __utility/as_const.h
   __utility/as_lvalue.h
-  __utility/auto_cast.h
   __utility/cmp.h
   __utility/convert_to_integral.h
   __utility/declval.h
diff --git a/libcxx/include/__ranges/access.h b/libcxx/include/__ranges/access.h
index 263fdd637fd965..45eee14e48b0cf 100644
--- a/libcxx/include/__ranges/access.h
+++ b/libcxx/include/__ranges/access.h
@@ -19,7 +19,6 @@
 #include <__type_traits/is_reference.h>
 #include <__type_traits/remove_cvref.h>
 #include <__type_traits/remove_reference.h>
-#include <__utility/auto_cast.h>
 #include <__utility/declval.h>
 #include <cstddef>
 
@@ -42,7 +41,7 @@ namespace ranges {
 namespace __begin {
 template <class _Tp>
 concept __member_begin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
-  { _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator;
+  { auto(__t.begin()) } -> input_or_output_iterator;
 };
 
 void begin(auto&)       = delete;
@@ -51,7 +50,7 @@ void begin(const auto&) = delete;
 template <class _Tp>
 concept __unqualified_begin =
     !__member_begin<_Tp> && __can_borrow<_Tp> && __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) {
-      { _LIBCPP_AUTO_CAST(begin(__t)) } -> input_or_output_iterator;
+      { auto(begin(__t)) } -> input_or_output_iterator;
     };
 
 struct __fn {
@@ -71,16 +70,14 @@ struct __fn {
 
   template <class _Tp>
     requires __member_begin<_Tp>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.begin()))) {
-    return _LIBCPP_AUTO_CAST(__t.begin());
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(auto(__t.begin()))) {
+    return auto(__t.begin());
   }
 
   template <class _Tp>
     requires __unqualified_begin<_Tp>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(begin(__t)))) {
-    return _LIBCPP_AUTO_CAST(begin(__t));
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(auto(begin(__t)))) {
+    return auto(begin(__t));
   }
 
   void operator()(auto&&) const = delete;
@@ -106,7 +103,7 @@ namespace __end {
 template <class _Tp>
 concept __member_end = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
   typename iterator_t<_Tp>;
-  { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>;
+  { auto(__t.end()) } -> sentinel_for<iterator_t<_Tp>>;
 };
 
 void end(auto&)       = delete;
@@ -116,7 +113,7 @@ template <class _Tp>
 concept __unqualified_end =
     !__member_end<_Tp> && __can_borrow<_Tp> && __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) {
       typename iterator_t<_Tp>;
-      { _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for<iterator_t<_Tp>>;
+      { auto(end(__t)) } -> sentinel_for<iterator_t<_Tp>>;
     };
 
 struct __fn {
@@ -129,16 +126,14 @@ struct __fn {
 
   template <class _Tp>
     requires __member_end<_Tp>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.end()))) {
-    return _LIBCPP_AUTO_CAST(__t.end());
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(auto(__t.end()))) {
+    return auto(__t.end());
   }
 
   template <class _Tp>
     requires __unqualified_end<_Tp>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(end(__t)))) {
-    return _LIBCPP_AUTO_CAST(end(__t));
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(auto(end(__t)))) {
+    return auto(end(__t));
   }
 
   void operator()(auto&&) const = delete;
@@ -193,9 +188,8 @@ struct __fn {
 
   template <class _Tp>
     requires is_rvalue_reference_v<_Tp&&>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
-      noexcept(noexcept(ranges::end(static_cast<const _Tp&&>(__t))))
-          -> decltype(ranges::end(static_cast<const _Tp&&>(__t))) {
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(
+      noexcept(ranges::end(static_cast<const _Tp&&>(__t)))) -> decltype(ranges::end(static_cast<const _Tp&&>(__t))) {
     return ranges::end(static_cast<const _Tp&&>(__t));
   }
 };
diff --git a/libcxx/include/__ranges/all.h b/libcxx/include/__ranges/all.h
index b735bdc7166ca3..5467ac0633b46e 100644
--- a/libcxx/include/__ranges/all.h
+++ b/libcxx/include/__ranges/all.h
@@ -21,7 +21,6 @@
 #include <__ranges/range_adaptor.h>
 #include <__ranges/ref_view.h>
 #include <__type_traits/decay.h>
-#include <__utility/auto_cast.h>
 #include <__utility/declval.h>
 #include <__utility/forward.h>
 
@@ -40,9 +39,8 @@ struct __fn : __range_adaptor_closure<__fn> {
   template <class _Tp>
     requires ranges::view<decay_t<_Tp>>
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))))
-          -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))) {
-    return _LIBCPP_AUTO_CAST(std::forward<_Tp>(__t));
+      noexcept(noexcept(auto(std::forward<_Tp>(__t)))) -> decltype(auto(std::forward<_Tp>(__t))) {
+    return auto(std::forward<_Tp>(__t));
   }
 
   template <class _Tp>
diff --git a/libcxx/include/__ranges/data.h b/libcxx/include/__ranges/data.h
index 18002bb52cc8ce..5a2f2e76218041 100644
--- a/libcxx/include/__ranges/data.h
+++ b/libcxx/include/__ranges/data.h
@@ -22,7 +22,6 @@
 #include <__type_traits/is_reference.h>
 #include <__type_traits/remove_pointer.h>
 #include <__type_traits/remove_reference.h>
-#include <__utility/auto_cast.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -41,7 +40,7 @@ concept __ptr_to_object = is_pointer_v<_Tp> && is_object_v<remove_pointer_t<_Tp>
 
 template <class _Tp>
 concept __member_data = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
-  { _LIBCPP_AUTO_CAST(__t.data()) } -> __ptr_to_object;
+  { auto(__t.data()) } -> __ptr_to_object;
 };
 
 template <class _Tp>
diff --git a/libcxx/include/__ranges/drop_view.h b/libcxx/include/__ranges/drop_view.h
index 83bb598b0a0c91..05df972c601032 100644
--- a/libcxx/include/__ranges/drop_view.h
+++ b/libcxx/include/__ranges/drop_view.h
@@ -39,7 +39,6 @@
 #include <__type_traits/is_nothrow_constructible.h>
 #include <__type_traits/make_unsigned.h>
 #include <__type_traits/remove_cvref.h>
-#include <__utility/auto_cast.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>
 #include <cstddef>
@@ -211,9 +210,8 @@ struct __fn {
   template <class _Range, convertible_to<range_difference_t<_Range>> _Np>
     requires __is_empty_view<remove_cvref_t<_Range>>
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&&) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
-          -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))) {
-    return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range));
+      noexcept(noexcept(auto(std::forward<_Range>(__range)))) -> decltype(auto(std::forward<_Range>(__range))) {
+    return auto(std::forward<_Range>(__range));
   }
 
   // [range.drop.overview]: the `span | basic_string_view | iota_view | subrange (StoreSize == false)` case.
@@ -279,9 +277,9 @@ struct __fn {
     requires (__is_repeat_specialization<_RawRange> && !sized_range<_RawRange>)
   _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI
   constexpr auto operator()(_Range&& __range, _Np&&) const
-    noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
-    -> decltype(      _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))
-    { return          _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); }
+    noexcept(noexcept(auto(std::forward<_Range>(__range))))
+    -> decltype(      auto(std::forward<_Range>(__range)))
+    { return          auto(std::forward<_Range>(__range)); }
 #endif
   // clang-format on
 
@@ -289,14 +287,14 @@ struct __fn {
   template <class _Range, convertible_to<range_difference_t<_Range>> _Np, class _RawRange = remove_cvref_t<_Range>>
   // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other
   // overloads.
-    requires(
-        !(__is_empty_view<_RawRange> ||
+    requires(!(__is_empty_view<_RawRange> ||
 #  if _LIBCPP_STD_VER >= 23
-          __is_repeat_specialization<_RawRange> ||
+               __is_repeat_specialization<_RawRange> ||
 #  endif
-          (__is_subrange_specialization_with_store_size<_RawRange> && sized_range<_RawRange> &&
-           random_access_range<_RawRange>) ||
-          (__is_passthrough_specialization<_RawRange> && sized_range<_RawRange> && random_access_range<_RawRange>)))
+               (__is_subrange_specialization_with_store_size<_RawRange> && sized_range<_RawRange> &&
+                random_access_range<_RawRange>) ||
+               (__is_passthrough_specialization<_RawRange> && sized_range<_RawRange> &&
+                random_access_range<_RawRange>)))
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const
       noexcept(noexcept(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n))))
           -> decltype(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n))) {
diff --git a/libcxx/include/__ranges/rbegin.h b/libcxx/include/__ranges/rbegin.h
index 7111201ae7d6bb..54d2c6a2be2b16 100644
--- a/libcxx/include/__ranges/rbegin.h
+++ b/libcxx/include/__ranges/rbegin.h
@@ -21,7 +21,6 @@
 #include <__type_traits/is_reference.h>
 #include <__type_traits/remove_cvref.h>
 #include <__type_traits/remove_reference.h>
-#include <__utility/auto_cast.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -37,7 +36,7 @@ namespace ranges {
 namespace __rbegin {
 template <class _Tp>
 concept __member_rbegin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
-  { _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator;
+  { auto(__t.rbegin()) } -> input_or_output_iterator;
 };
 
 void rbegin(auto&)       = delete;
@@ -46,7 +45,7 @@ void rbegin(const auto&) = delete;
 template <class _Tp>
 concept __unqualified_rbegin =
     !__member_rbegin<_Tp> && __can_borrow<_Tp> && __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) {
-      { _LIBCPP_AUTO_CAST(rbegin(__t)) } -> input_or_output_iterator;
+      { auto(rbegin(__t)) } -> input_or_output_iterator;
     };
 
 template <class _Tp>
@@ -60,15 +59,15 @@ struct __fn {
   template <class _Tp>
     requires __member_rbegin<_Tp>
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rbegin()))) {
-    return _LIBCPP_AUTO_CAST(__t.rbegin());
+      noexcept(noexcept(auto(__t.rbegin()))) {
+    return auto(__t.rbegin());
   }
 
   template <class _Tp>
     requires __unqualified_rbegin<_Tp>
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(rbegin(__t)))) {
-    return _LIBCPP_AUTO_CAST(rbegin(__t));
+      noexcept(noexcept(auto(rbegin(__t)))) {
+    return auto(rbegin(__t));
   }
 
   template <class _Tp>
diff --git a/libcxx/include/__ranges/rend.h b/libcxx/include/__ranges/rend.h
index 58d98aafd264b8..15b89c90625478 100644
--- a/libcxx/include/__ranges/rend.h
+++ b/libcxx/include/__ranges/rend.h
@@ -22,7 +22,6 @@
 #include <__type_traits/is_reference.h>
 #include <__type_traits/remove_cvref.h>
 #include <__type_traits/remove_reference.h>
-#include <__utility/auto_cast.h>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -39,7 +38,7 @@ namespace __rend {
 template <class _Tp>
 concept __member_rend = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
   ranges::rbegin(__t);
-  { _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
+  { auto(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
 };
 
 void rend(auto&)       = delete;
@@ -49,7 +48,7 @@ template <class _Tp>
 concept __unqualified_rend =
     !__member_rend<_Tp> && __can_borrow<_Tp> && __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) {
       ranges::rbegin(__t);
-      { _LIBCPP_AUTO_CAST(rend(__t)) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
+      { auto(rend(__t)) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
     };
 
 template <class _Tp>
@@ -62,16 +61,14 @@ class __fn {
 public:
   template <class _Tp>
     requires __member_rend<_Tp>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rend()))) {
-    return _LIBCPP_AUTO_CAST(__t.rend());
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(auto(__t.rend()))) {
+    return auto(__t.rend());
   }
 
   template <class _Tp>
     requires __unqualified_rend<_Tp>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(rend(__t)))) {
-    return _LIBCPP_AUTO_CAST(rend(__t));
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(auto(rend(__t)))) {
+    return auto(rend(__t));
   }
 
   template <class _Tp>
@@ -105,9 +102,8 @@ struct __fn {
 
   template <class _Tp>
     requires is_rvalue_reference_v<_Tp&&>
-  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
-      noexcept(noexcept(ranges::rend(static_cast<const _Tp&&>(__t))))
-          -> decltype(ranges::rend(static_cast<const _Tp&&>(__t))) {
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(
+      noexcept(ranges::rend(static_cast<const _Tp&&>(__t)))) -> decltype(ranges::rend(static_cast<const _Tp&&>(__t))) {
     return ranges::rend(static_cast<const _Tp&&>(__t));
   }
 };
diff --git a/libcxx/include/__ranges/size.h b/libcxx/include/__ranges/size.h
index 14e21aae6bf1d5..92a50d3ddc74b6 100644
--- a/libcxx/include/__ranges/size.h
+++ b/libcxx/include/__ranges/size.h
@@ -20,7 +20,6 @@
 #include <__type_traits/make_signed.h>
 #include <__type_traits/make_unsigned.h>
 #include <__type_traits/remove_cvref.h>
-#include <__utility/auto_cast.h>
 #include <__utility/declval.h>
 #include <cstddef>
 
@@ -49,13 +48,13 @@ concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>;
 
 template <class _Tp>
 concept __member_size = __size_enabled<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
-  { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like;
+  { auto(__t.size()) } -> __integer_like;
 };
 
 template <class _Tp>
 concept __unqualified_size =
     __size_enabled<_Tp> && !__member_size<_Tp> && __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) {
-      { _LIBCPP_AUTO_CAST(size(__t)) } -> __integer_like;
+      { auto(size(__t)) } -> __integer_like;
     };
 
 template <class _Tp>
@@ -81,15 +80,15 @@ struct __fn {
   // `[range.prim.size]`: `auto(t.size())` is a valid expression.
   template <__member_size _Tp>
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.size()))) {
-    return _LIBCPP_AUTO_CAST(__t.size());
+      noexcept(noexcept(auto(__t.size()))) {
+    return auto(__t.size());
   }
 
   // `[range.prim.size]`: `auto(size(t))` is a valid expression.
   template <__unqualified_size _Tp>
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) {
-    return _LIBCPP_AUTO_CAST(size(__t));
+      noexcept(noexcept(auto(size(__t)))) {
+    return auto(size(__t));
   }
 
   // [range.prim.size]: the `to-unsigned-like` case.
diff --git a/libcxx/include/__ranges/take_view.h b/libcxx/include/__ranges/take_view.h
index 83ed5ca0ebd390..3c28154e4d4150 100644
--- a/libcxx/include/__ranges/take_view.h
+++ b/libcxx/include/__ranges/take_view.h
@@ -39,7 +39,6 @@
 #include <__type_traits/is_nothrow_constructible.h>
 #include <__type_traits/maybe_const.h>
 #include <__type_traits/remove_cvref.h>
-#include <__utility/auto_cast.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>
 #include <cstddef>
@@ -252,9 +251,8 @@ struct __fn {
   template <class _Range, convertible_to<range_difference_t<_Range>> _Np>
     requires __is_empty_view<remove_cvref_t<_Range>>
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&&) const
-      noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
-          -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))) {
-    return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range));
+      noexcept(noexcept(auto(std::forward<_Range>(__range)))) -> decltype(auto(std::forward<_Range>(__range))) {
+    return auto(std::forward<_Range>(__range));
   }
 
   // [range.take.overview]: the `span | basic_string_view | subrange` case.
diff --git a/libcxx/include/__utility/auto_cast.h b/libcxx/include/__utility/auto_cast.h
deleted file mode 100644
index 06715b3438f996..00000000000000
--- a/libcxx/include/__utility/auto_cast.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP___UTILITY_AUTO_CAST_H
-#define _LIBCPP___UTILITY_AUTO_CAST_H
-
-#include <__config>
-#include <__type_traits/decay.h>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#  pragma GCC system_header
-#endif
-
-#define _LIBCPP_AUTO_CAST(expr) static_cast<::std::__decay_t<decltype((expr))> >(expr)
-
-#endif // _LIBCPP___UTILITY_AUTO_CAST_H
diff --git a/libcxx/include/future b/libcxx/include/future
index fda1591818a667..989e9aef3d8976 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -388,7 +388,6 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
 #include <__system_error/error_condition.h>
 #include <__type_traits/aligned_storage.h>
 #include <__type_traits/strip_signature.h>
-#include <__utility/auto_cast.h>
 #include <__utility/forward.h>
 #include <__utility/move.h>
 #include <mutex>
@@ -1853,7 +1852,7 @@ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
 #  endif
     if (__does_policy_contain(__policy, launch::async))
       return std::__make_async_assoc_state<_Rp>(
-          _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...));
+          _BF(auto(std::forward<_Fp>(__f)), auto(std::forward<_Args>(__args))...));
 #  ifndef _LIBCPP_HAS_NO_EXCEPTIONS
   } catch (...) {
     if (__policy == launch::async)
@@ -1863,7 +1862,7 @@ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
 
   if (__does_policy_contain(__policy, launch::deferred))
     return std::__make_deferred_assoc_state<_Rp>(
-        _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...));
+        _BF(auto(std::forward<_Fp>(__f)), auto(std::forward<_Args>(__args))...));
   return future<_Rp>{};
 }
 
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 98890e890cdb13..bbf0c05557d0d7 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -2044,10 +2044,6 @@ module std_private_type_traits_void_t                                    [system
 
 module std_private_utility_as_const               [system] { header "__utility/as_const.h" }
 module std_private_utility_as_lvalue              [system] { header "__utility/as_lvalue.h" }
-module std_private_utility_auto_cast              [system] {
-  header "__utility/auto_cast.h"
-  export std_private_type_traits_decay
-}
 module std_private_utility_cmp                    [system] {
   header "__utility/cmp.h"
   export std_private_type_traits_make_unsigned
diff --git a/libcxx/include/string b/libcxx/include/string
index ca5b3fa6a01472..d4c1e20976696c 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -612,7 +612,6 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
 #include <__type_traits/noexcept_move_assign_container.h>
 #include <__type_traits/remove_cvref.h>
 #include <__type_traits/void_t.h>
-#include <__utility/auto_cast.h>
 #include <__utility/declval.h>
 #include <__utility/forward.h>
 #include <__utility/is_pointer_in_range.h>
@@ -1221,7 +1220,7 @@ public:
   template <class _Op>
   _LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) {
     __resize_default_init(__n);
-    __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n)));
+    __erase_to_end(std::move(__op)(data(), auto(__n)));
   }
 #endif
 
diff --git a/libcxx/include/utility b/libcxx/include/utility
index 90713da621c5da..f5ecad673ac53c 100644
--- a/libcxx/include/utility
+++ b/libcxx/include/utility
@@ -249,7 +249,6 @@ template <class T>
 #include <__config>
 #include <__utility/as_const.h>
 #include <__utility/as_lvalue.h>
-#include <__utility/auto_cast.h>
 #include <__utility/cmp.h>
 #include <__utility/declval.h>
 #include <__utility/exception_guard.h>



More information about the libcxx-commits mailing list