Browse Source

C++ 不允许直接对 std::array<T1, N> 进行 static_cast 到 std::array<T2, N>,即使 T1 和 T2 是可转换类型。

改成显式地把每一个 unsigned long long 元素转换为 uint32_t
wch
mckay 1 week ago
parent
commit
a1572260fb
  1. 7
      network_process/interface/fwd_types.hpp

7
network_process/interface/fwd_types.hpp

@ -267,7 +267,12 @@ template <size_t N>
struct equal_to<pod_key_t<N>> { struct equal_to<pod_key_t<N>> {
bool operator()(const pod_key_t<N>& k1, const pod_key_t<N>& k2) const bool operator()(const pod_key_t<N>& k1, const pod_key_t<N>& k2) const
{ {
return static_cast<std::array<uint32_t, N>>(k1) == static_cast<std::array<uint32_t, N>>(k2); std::array<uint32_t, N> a, b;
for (size_t i = 0; i < N; ++i) {
a[i] = static_cast<uint32_t>(k1[i]);
b[i] = static_cast<uint32_t>(k2[i]);
}
return a == b;
} }
}; };
} // namespace std } // namespace std
Loading…
Cancel
Save