名前空間
変種
操作

「cpp/string/basic string/operator basic string view」の版間の差分

提供: cppreference.com
< cpp‎ | string‎ | basic string
(関連項目)
 
62行: 62行:
 
{{dsc end}}
 
{{dsc end}}
  
{{langlinks|en|es|fr|zh}}
+
{{langlinks|en|es|fr|zh}}

2023年10月20日 (金) 04:27時点における最新版

 
 
 
std::basic_string
 
operator std::basic_string_view<CharT, Traits>() const noexcept;
(C++17以上)
(C++20未満)
constexpr operator std::basic_string_view<CharT, Traits>() const noexcept;
(C++20以上)

std::basic_string_view<CharT, Traits>(data(), size()) によって行われたかのように構築された、 std::basic_string_view を返します。

目次

[編集] 引数

(なし)

[編集] 戻り値

文字列全体の内容を表す文字列ビュー。

[編集]

#include <iostream>
#include <string>
#include <string_view>
 
void show_wstring_size(std::wstring_view wcstr_v)
{
  std::cout << wcstr_v.size() << " code points\n";
}
 
int main()
{
  std::string cppstr = "ラーメン";   // narrow string