namespace std {
size_t wcscspn(const wchar_t* s1, const wchar_t* s2);
}
概要
ワイド文字列の先頭から、指定した集合に含まれない文字が続く長さを取得する。
戻り値
s1が指す文字列の先頭から、s2が指す文字列に含まれない文字だけが並んでいる部分の長さを返す。
備考
- この関数は、C++26からフリースタンディング処理系でも使用できる
例
#include <cwchar>
#include <iostream>
int main()
{
// 先頭から "lo" に含まれない文字が続く長さ
std::wcout << std::wcscspn(L"hello", L"lo") << std::endl;
}
出力
2
バージョン
言語
- C++98
関連項目
wcsspnwcspbrkstd::strcspn(): マルチバイト文字列版
参照
- P2338R4 Freestanding Library: Character primitives and the C library
- C++26で、この関数がフリースタンディング処理系で使用可能になった