* 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;
maxSize_(maxSize),
clearSize_(clearSize) { }
+ EvictingCacheMap(const EvictingCacheMap&) = delete;
+ EvictingCacheMap& operator=(const EvictingCacheMap&) = delete;
+ EvictingCacheMap(EvictingCacheMap&&) = default;
+ EvictingCacheMap& operator=(EvictingCacheMap&&) = default;
~EvictingCacheMap() {
setPruneHook(nullptr);
EXPECT_EQ(-1, expected);
}
}
+
+TEST(EvictingCacheMap, MoveTest) {
+ const int nItems = 1000;
+ EvictingCacheMap<int, int> map(nItems);
+ for (int i = 0; i < nItems; i++) {
+ map.set(i, i);
+ EXPECT_TRUE(map.exists(i));
+ EXPECT_EQ(i, map.get(i));
+ }
+
+ EvictingCacheMap<int, int> map2 = std::move(map);
+ EXPECT_TRUE(map.empty());
+ for (int i = 0; i < nItems; i++) {
+ EXPECT_TRUE(map2.exists(i));
+ EXPECT_EQ(i, map2.get(i));
+ }
+}