Explore resources, tutorials, API docs, and dynamic examples to get the most out of OpenAI's developer platform.
![OpenAI Platform](https://cdn-ak-scissors.b.st-hatena.com/image/square/24af691809b62bb4af22de9a59752795a4d8402f/height=288;version=1;width=512/https%3A%2F%2Fcdn.openai.com%2FAPI%2Fimages%2Fopengraph.png)
あらまし strlen() という関数がある。御存知の通り、文字列の長さを算出する標準 C ライブラリの関数だ。 やってることは単純で、例えば以下のように実装できる。 size_t strlen_simple(const char* str) { const char* p = str; while (*p) ++p; return size_t(p - str); } '\0' が見つかるまでポインタを進め、初期位置との差分を返すだけだ。これで機能的には std::strlen() と同等である。 では、速度的にはどうだろう?適当にベンチマークを書いて MSVC 2022 でコンパイル&実行するとこうなった。
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く