Use nullptr rather than 0 for a null pointer
[folly.git] / folly / EvictingCacheMap.h
index 3059fb5e5e2575924f66aeb90fddd1549f0787ff..e7e8149d7eae056df0b84d0b82c1509072050b0d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <exception>
 #include <functional>
 
-#include <boost/utility.hpp>
 #include <boost/intrusive/list.hpp>
 #include <boost/intrusive/unordered_set.hpp>
 #include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/utility.hpp>
+
+#include <folly/portability/BitsFunctexcept.h>
 
 namespace folly {
 
@@ -89,9 +91,8 @@ namespace folly {
  * unless evictions of LRU items are triggered by calling prune() by clients
  * (using their own eviction criteria).
  */
-template <class TKey, class TValue, class THash = std::hash<TKey> >
-class EvictingCacheMap : private boost::noncopyable {
-
+template <class TKey, class TValue, class THash = std::hash<TKey>>
+class EvictingCacheMap {
  private:
   // typedefs for brevity
   struct Node;
@@ -147,6 +148,10 @@ class EvictingCacheMap : private boost::noncopyable {
         maxSize_(maxSize),
         clearSize_(clearSize) { }
 
+  EvictingCacheMap(const EvictingCacheMap&) = delete;
+  EvictingCacheMap& operator=(const EvictingCacheMap&) = delete;
+  EvictingCacheMap(EvictingCacheMap&&) = default;
+  EvictingCacheMap& operator=(EvictingCacheMap&&) = default;
 
   ~EvictingCacheMap() {
     setPruneHook(nullptr);
@@ -205,7 +210,7 @@ class EvictingCacheMap : private boost::noncopyable {
   TValue& get(const TKey& key) {
     auto it = find(key);
     if (it == end()) {
-      throw std::out_of_range("Key does not exist");
+      std::__throw_out_of_range("Key does not exist");
     }
     return it->second;
   }
@@ -237,7 +242,7 @@ class EvictingCacheMap : private boost::noncopyable {
   const TValue& getWithoutPromotion(const TKey& key) const {
     auto it = findWithoutPromotion(key);
     if (it == end()) {
-      throw std::out_of_range("Key does not exist");
+      std::__throw_out_of_range("Key does not exist");
     }
     return it->second;
   }
@@ -490,4 +495,4 @@ class EvictingCacheMap : private boost::noncopyable {
   std::size_t clearSize_;
 };
 
-} // folly
+} // namespace folly