You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/05/27 18:35:34 UTC

[GitHub] [arrow] bkietz commented on a change in pull request #10414: [C++]: C++17 test PR

bkietz commented on a change in pull request #10414:
URL: https://github.com/apache/arrow/pull/10414#discussion_r640868604



##########
File path: cpp/src/arrow/util/cache_internal.h
##########
@@ -174,22 +172,17 @@ template <template <typename...> class Cache, template <typename...> class Memoi
           typename RetType = typename Memoizer::RetType>
 static std::function<RetType(const Key&)> Memoize(Func&& func, int32_t cache_capacity) {
   // std::function<> requires copy constructibility
-  struct {
-    RetType operator()(const Key& key) const { return (*memoized_)(key); }
-    std::shared_ptr<Memoizer> memoized_;
-  } shared_memoized = {
-      std::make_shared<Memoizer>(std::forward<Func>(func), cache_capacity)};
-
-  return shared_memoized;
+  auto memoized = std::make_shared<Memoizer>(std::forward<Func>(func), cache_capacity);
+  return [memoized = std::move(memoized)](const Key& key) -> RetType {
+    return (*memoized)(key);
+  };
 }
 
 }  // namespace detail
 
 // Apply a LRU memoization cache to a callable.
 template <typename Func>
-static auto MemoizeLru(Func&& func, int32_t cache_capacity)
-    -> decltype(detail::Memoize<LruCache, detail::ThreadSafeMemoizer>(
-        std::forward<Func>(func), cache_capacity)) {
+static auto MemoizeLru(Func&& func, int32_t cache_capacity) -> auto {

Review comment:
       ```suggestion
   static auto MemoizeLru(Func&& func, int32_t cache_capacity) {
   ```

##########
File path: cpp/src/arrow/util/cache_internal.h
##########
@@ -199,9 +192,7 @@ static auto MemoizeLru(Func&& func, int32_t cache_capacity)
 // A recommended usage is to declare per-thread caches using `thread_local`
 // (see cache_benchmark.cc).
 template <typename Func>
-static auto MemoizeLruThreadUnsafe(Func&& func, int32_t cache_capacity)
-    -> decltype(detail::Memoize<LruCache, detail::ThreadUnsafeMemoizer>(
-        std::forward<Func>(func), cache_capacity)) {
+static auto MemoizeLruThreadUnsafe(Func&& func, int32_t cache_capacity) -> auto {

Review comment:
       ```suggestion
   static auto MemoizeLruThreadUnsafe(Func&& func, int32_t cache_capacity) {
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org