GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::basic_string::operator basic_string_view - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. string
  3. basic_string
  4. operator basic_string_view

最終更新日時: 2026年07月22日 16時08分23秒 (JST)
rotarymars が更新

履歴 編集

function
<string>

std::basic_string::operator basic_string_view(C++17)

operator basic_string_view<charT, traits>() const noexcept;           // (1) C++17
constexpr operator basic_string_view<charT, traits>() const noexcept; // (1) C++20

概要

std::basic_string_view型に変換する。

戻り値

以下と等価:

return std::basic_string_view<charT, traits>(data(), size());

例外

投げない

例

#include <iostream>
#include <string>
#include <string_view>

int main()
{
  std::string s = "Hello World";
  std::string_view sv = s;

  std::cout << sv.substr(0, 5) << std::endl;
  std::cout << s << std::endl;
}

出力

Hello
Hello World

参照

  • P0254R2 Integrating std::string_view and std::string
  • P0980R1 Making std::string constexpr
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.