Przeglądaj źródła

Solving implicit cast warnings.

Samuel Jaffe 8 lat temu
rodzic
commit
84ed04ec61
2 zmienionych plików z 4 dodań i 4 usunięć
  1. 2 2
      bucket_hash_map.hpp
  2. 2 2
      bucket_hash_set.hpp

+ 2 - 2
bucket_hash_map.hpp

@@ -103,7 +103,7 @@ public:
   }
   template <typename InputIt>
   void insert(InputIt first, InputIt last) {
-    maybe_expand(std::distance(first, last));
+    maybe_expand(static_cast<std::size_t>(std::distance(first, last)));
     while (first != last) { insert(*first++); }
   }
   void insert(std::initializer_list<value_type> ilist) { insert(ilist.begin(), ilist.end()); }
@@ -220,7 +220,7 @@ private:
   
   template <typename Bucket>
   auto lookup_impl(Bucket & bkt, key_type const & key) const -> std::pair<decltype(bkt.begin()), decltype(bkt.begin()->begin())> {
-    auto listit = bkt.begin() + bucket(key);
+    auto listit = bkt.begin() + static_cast<std::ptrdiff_t>(bucket(key));
     auto it = search(listit, key);
     return {listit, it};
   }

+ 2 - 2
bucket_hash_set.hpp

@@ -102,7 +102,7 @@ public:
   }
   template <typename InputIt>
   void insert(InputIt first, InputIt last) {
-    maybe_expand(std::distance(first, last));
+    maybe_expand(static_cast<std::size_t>(std::distance(first, last)));
     while (first != last) { insert(*first++); }
   }
   void insert(std::initializer_list<value_type> ilist) { insert(ilist.begin(), ilist.end()); }
@@ -175,7 +175,7 @@ private:
   
   template <typename Bucket>
   auto lookup_impl(Bucket & bkt, key_type const & key) const -> std::pair<decltype(bkt.begin()), decltype(bkt.begin()->begin())> {
-    auto listit = bkt.begin() + bucket(key);
+    auto listit = bkt.begin() + static_cast<std::ptrdiff_t>(bucket(key));
     auto it = search(listit, key);
     return {listit, it};
   }