Upgrade to Pro — share decks privately, control downloads, hide ads and more …

string_view.pdf

Cranberries
January 18, 2019
670

 string_view.pdf

Cranberries

January 18, 2019
Tweet

Transcript

  1. 宣⾔等 宣⾔等 以降はメンバに CharT*data_ size_typesize_ を持つもののして進めていきます namespacestd{ template<classCharT,classTraits=char_traits<CharT>> classbasic_string_view; 

    usingbasic_string_view=basic_string_view<char>; usingu16basic_string_view=basic_string_view<char16_t>; usingu32basic_string_view=basic_string_view<char32_t>; usingwbasic_string_view=basic_string_view<wchar_t>; }
  2. member types member types //types usingtraits_type=traits; usingvalue_type=charT; usingpointer=value_type*; usingconst_pointer=constvalue_type*; usingreference=value_type&;

    usingconst_reference=constvalue_type&; usingconst_iterator=implementation-defined; usingiterator=const_iterator; usingconst_reverse_iterator=reverse_iterator<const_iterator>; usingreverse_iterator=const_reverse_iterator; usingsize_type=size_t; usingdifference_type=ptrdiff_t; staticconstexprsize_typenpos=size_type(-1);
  3. compare( 続き) compare( 続き) (1):⽂字列の全体同⼠の⽐較 (2):呼び出し元の部分⽂字列と引数の⽂字列全体の⽐較 substr(pos1,n1).compare(str)と等価 (3):部分⽂字列同⼠の⽐較 substr(pos1,n1).compare(str.substr(pos2,n2))と等価 constexprintcompare(basic_string_viewsv)constnoexcept;//(1)

     constexprintcompare(size_typepos1, size_typen1, basic_string_viewsv)const;//(2)  constexprintcompare(size_typepos1, size_typen1, basic_string_viewsv, size_typepos2, size_typen2)const;//(3)
  4. compare( 続き) compare( 続き) 基本的に引数がbasic_string_viewから⽂字列のポインタに変わっただけ (4)、(5)はsをbasic_string_view(s)にして先程のものを呼び出すものと等価である (6)は、ポインタが部分⽂字列の先頭を指すものとされており注意が必要 constexprintcompare(constCharT*s)const;//(4)  constexprintcompare(size_typepos1,

    size_typen1, constCharT*s)const;//(5)  constexprintcompare(size_typepos1, size_typen1, constCharT*s, size_typen2)const;//(6)
  5. Searching Searching find, rfind, find_first_of, find_last_of, find_first_not_of, and find_last_not_of. find,

    rfind, find_first_of, find_last_of, find_first_not_of, and find_last_not_of.