tkomatsu/webserv

C++では名前付きキャストを使うべき

Closed this issue · 0 comments

Cの形式での明示的キャストではなく、C++の名前付きキャストを使うべきだと思います。

暗黙的キャスト

char *src = "hello";
unsigned char *dst = src;

Cの明示的キャスト

char *src = "hello";
unsigned char *dst = (unsigned char *)src;

名前付きキャスト

char *src = "hello";
unsigned char *dst = reinterpret_cast<unsigned char *>(src);

webserv/srcs/utility.cpp

Lines 95 to 96 in e8dd78f

const unsigned char *p1 = (const unsigned char *)a.c_str();
const unsigned char *p2 = (const unsigned char *)b.c_str();