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_spanstream::span - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. spanstream
  3. basic_spanstream
  4. span

最終更新日時: 2025年08月11日 15時35分16秒 (JST)
suomesta が更新

履歴 編集

function
<spanstream>

std::basic_spanstream::span(C++23)

std::span<charT> span() const noexcept; // (1)

void span(std::span<charT> s) noexcept; // (2)

概要

固定長バッファの取得または設定をする。

  • (1) : std::span 型の固定長バッファを取得する
  • (2) : std::span 型の固定長バッファ s を設定する

効果

  • (1) : return rdbuf()->span(); と同等
  • (2) : rdbuf()->span(s) と同等

例

#include <iostream>
#include <span>
#include <spanstream>

int main()
{
  char buf1[32] = "default";
  std::span<char> span1{buf1};
  std::spanstream ss{span1};

  // (1)
  std::span<char> read = ss.span();

  std::cout << "(1)" << std::endl;
  std::cout << read.data() << std::endl;
  std::cout << std::endl;

  char buf2[32] = "overwritten";
  std::span<char> span2{buf2};

  // (2)
  ss.span(span2);

  std::cout << "(2)" << std::endl;
  std::cout << ss.span().data() << std::endl;
}

出力

(1)
default

(2)
overwritten

バージョン

言語

  • C++23

処理系

  • Clang: ??
  • GCC: ??
  • Visual C++: ??

関連項目

  • basic_spanbuf::span
You are visitor 01402520 — 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.