MCPcopy Create free account
hub / github.com/boostorg/parser / contains

Method contains

include/boost/parser/parser.hpp:1907–1950  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1905 {
1906 template<typename T, typename Context>
1907 bool contains(T c_, Context const & context) const
1908 {
1909 if constexpr (SortedUTF32) {
1910 return std::binary_search(chars_.begin(), chars_.end(), c_);
1911 }
1912
1913 if (context.no_case_depth_) {
1914 case_fold_array_t folded;
1915 auto folded_last = detail::case_fold(c_, folded.begin());
1916 if constexpr (std::is_same_v<T, char32_t>) {
1917 auto const cps = chars_ | text::as_utf32;
1918 auto chars_first = no_case_iter(cps.begin(), cps.end());
1919 auto chars_last = cps.end();
1920 auto result = text::search(
1921 chars_first,
1922 chars_last,
1923 folded.begin(),
1924 folded_last);
1925 return !result.empty();
1926 } else {
1927 auto chars_first =
1928 no_case_iter(chars_.begin(), chars_.end());
1929 auto chars_last = chars_.end();
1930 auto result = text::search(
1931 chars_first,
1932 chars_last,
1933 folded.begin(),
1934 folded_last);
1935 return !result.empty();
1936 }
1937 } else {
1938 if constexpr (std::is_same_v<T, char32_t>) {
1939 auto const cps = chars_ | text::as_utf32;
1940 return text::find(cps.begin(), cps.end(), c_) !=
1941 cps.end();
1942 } else {
1943 using element_type =
1944 remove_cv_ref_t<decltype(*chars_.begin())>;
1945 element_type const c = c_;
1946 return text::find(chars_.begin(), chars_.end(), c) !=
1947 chars_.end();
1948 }
1949 }
1950 }
1951
1952 BOOST_PARSER_SUBRANGE<Iter, Sentinel> chars_;
1953 };

Callers 1

callMethod · 0.80

Calls 7

case_foldFunction · 0.85
no_case_iterClass · 0.85
searchFunction · 0.85
findFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected