std::basic_string_view<CharT,Traits>::npos
cppreference.net에서 가져옴
static constexpr size_type npos = size_type(-1);
|
(C++17부터) | |
이는 size_type 형식이 나타낼 수 있는 최대값과 같은 특수 값입니다. 정확한 의미는 문맥에 따라 다르지만, 일반적으로 뷰 인덱스를 기대하는 함수에서 뷰의 끝을 나타내거나 뷰 인덱스를 반환하는 함수에서 오류 표시기로 사용됩니다.
예제
이 코드 실행
#include <string_view> constexpr bool contains(std::string_view const what, std::string_view const where) noexcept { return std::string_view::npos != where.find(what); } int main() { using namespace std::literals; static_assert(contains("water", "in a bottle of water")); static_assert(!contains("wine", "in a bottle of champagne")); static_assert(""sv.npos == "haystack"sv.find("needle")); }
참고 항목
constexpr
size_type
npos
[static]
|
특수 값 size_type ( - 1 ) , 정확한 의미는 컨텍스트에 따라 다름 |