Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lihuiba committed Apr 22, 2024
1 parent cd4985c commit 2d4d715
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
14 changes: 4 additions & 10 deletions common/string-keyed.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class basic_map_string_kv : public M
const_iterator end() const
{
auto it = base::end();
return __reinterpret_cast<B_IT>(it);
return reinterpret_cast<B_IT&>(it);
}
iterator end()
{
Expand All @@ -351,16 +351,10 @@ class basic_map_string_kv : public M
{
return find(k)->second;
}
template<typename T, typename P>
T& __reinterpret_cast(P& x) const {
static_assert(sizeof(P) == sizeof(T), "...");
auto y = (T*)&x;
return *y;
}
const_iterator find ( const key_type& k ) const
{
auto it = base::find((const skvm&)k);
return __reinterpret_cast<B_IT>(it);
return reinterpret_cast<B_IT&>(it);
}
iterator find ( const key_type& k )
{
Expand All @@ -374,8 +368,8 @@ class basic_map_string_kv : public M
std::pair<const_iterator,const_iterator> equal_range ( const key_type& k ) const
{
auto r = base::equal_range((const skvm&)k);
return {__reinterpret_cast<B_IT>(r.first),
__reinterpret_cast<B_IT>(r.second)};
return {reinterpret_cast<B_IT&>(r.first),
reinterpret_cast<B_IT&>(r.second)};
}
std::pair<iterator, bool> emplace (const key_type& k, const mapped_type& v )
{
Expand Down
6 changes: 0 additions & 6 deletions common/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,6 @@ int version_compare(std::string_view a, std::string_view b, int& result);
int kernel_version_compare(std::string_view dst, int& result);
void print_stacktrace();

template<typename T, typename P> inline
T& __reinterpret_cast(P& x) noexcept {
auto y = (T*)&x;
return *y;
}

namespace photon {

// Saturating addition, no upward overflow
Expand Down
2 changes: 1 addition & 1 deletion net/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ bool server_down = false;
photon::thread* server_thread = nullptr;

void* serve_connection(void* arg) {
auto fd = __reinterpret_cast<int>(arg);
auto fd = (int)(uint64_t)arg;
while (true) {
char buf[1024];
auto ret = net::read(fd, buf, sizeof(buf));
Expand Down

0 comments on commit 2d4d715

Please sign in to comment.