[llvm] r283800 - Rename llvm::apply -> llvm::apply_tuple.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 10 14:24:35 PDT 2016


Author: zturner
Date: Mon Oct 10 16:24:34 2016
New Revision: 283800

URL: http://llvm.org/viewvc/llvm-project?rev=283800&view=rev
Log:
Rename llvm::apply -> llvm::apply_tuple.

llvm::cl already has a function called llvm::apply() so this is
causing an ODR violation.  The STLExtras version should win the
vote on which one gets to be called apply() since it is named
after the equivalent STL function, but since renaiming the cl
version is more difficult, let's do this for now to get the
bots green.

Modified:
    llvm/trunk/include/llvm/ADT/STLExtras.h
    llvm/trunk/unittests/ADT/STLExtrasTest.cpp

Modified: llvm/trunk/include/llvm/ADT/STLExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/STLExtras.h?rev=283800&r1=283799&r2=283800&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/STLExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/STLExtras.h Mon Oct 10 16:24:34 2016
@@ -693,7 +693,7 @@ template <typename R> detail::enumerator
 
 namespace detail {
 template <typename F, typename Tuple, std::size_t... I>
-auto apply_impl(F &&f, Tuple &&t, index_sequence<I...>)
+auto apply_tuple_impl(F &&f, Tuple &&t, index_sequence<I...>)
     -> decltype(std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...)) {
   return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...);
 }
@@ -703,15 +703,15 @@ auto apply_impl(F &&f, Tuple &&t, index_
 /// tuple variadically to f as if by calling f(a1, a2, ..., an) and
 /// return the result.
 template <typename F, typename Tuple>
-auto apply(F &&f, Tuple &&t) -> decltype(detail::apply_impl(
+auto apply_tuple(F &&f, Tuple &&t) -> decltype(detail::apply_tuple_impl(
     std::forward<F>(f), std::forward<Tuple>(t),
     build_index_impl<
-        std::tuple_size<typename std::decay<Tuple>::type>::value>())) {
+        std::tuple_size<typename std::decay<Tuple>::type>::value>{})) {
   using Indices = build_index_impl<
       std::tuple_size<typename std::decay<Tuple>::type>::value>;
 
-  return detail::apply_impl(std::forward<F>(f), std::forward<Tuple>(t),
-                            Indices());
+  return detail::apply_tuple_impl(std::forward<F>(f), std::forward<Tuple>(t),
+                                  Indices{});
 }
 } // End llvm namespace
 

Modified: llvm/trunk/unittests/ADT/STLExtrasTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/STLExtrasTest.cpp?rev=283800&r1=283799&r2=283800&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/STLExtrasTest.cpp (original)
+++ llvm/trunk/unittests/ADT/STLExtrasTest.cpp Mon Oct 10 16:24:34 2016
@@ -195,7 +195,7 @@ TEST(STLExtrasTest, EnumerateLifetimeSem
 
 TEST(STLExtrasTest, ApplyTuple) {
   auto T = std::make_tuple(1, 3, 7);
-  auto U = llvm::apply(
+  auto U = llvm::apply_tuple(
       [](int A, int B, int C) { return std::make_tuple(A - B, B - C, C - A); },
       T);
 
@@ -203,7 +203,7 @@ TEST(STLExtrasTest, ApplyTuple) {
   EXPECT_EQ(-4, std::get<1>(U));
   EXPECT_EQ(6, std::get<2>(U));
 
-  auto V = llvm::apply(
+  auto V = llvm::apply_tuple(
       [](int A, int B, int C) {
         return std::make_tuple(std::make_pair(A, char('A' + A)),
                                std::make_pair(B, char('A' + B)),
@@ -231,7 +231,7 @@ public:
 
 TEST(STLExtrasTest, ApplyTupleVariadic) {
   auto Items = std::make_tuple(1, llvm::StringRef("Test"), 'X');
-  auto Values = apply(apply_variadic(), Items);
+  auto Values = apply_tuple(apply_variadic(), Items);
 
   EXPECT_EQ(2, std::get<0>(Values));
   EXPECT_EQ("Tes", std::get<1>(Values));




More information about the llvm-commits mailing list