Skip to content

Latest commit

 

History

History
74 lines (53 loc) · 2.13 KB

File metadata and controls

74 lines (53 loc) · 2.13 KB

display_string

  • filesystem[meta header]
  • std::filesystem[meta namespace]
  • path[meta class]
  • function[meta id-type]
  • cpp26[meta cpp]
std::string display_string() const;

概要

表示に適したリテラルエンコーディングで、パス文字列を取得する。

std::format()std::print()で出力するのに適した文字列を返す。

戻り値

以下と等価である:

return std::format("{}", *this);
  • std::format[link /reference/format/format.md]

備考

  • 戻り値の文字列は、フォーマット (std::format()) や出力 (std::print()) で使用するのに適している
  • リテラルエンコーディングがUTF-8であり、パスが妥当なUnicodeであれば (Windowsのほとんどのパスがそうである)、文字コード変換は無損失となる

#include <print>
#include <filesystem>

namespace fs = std::filesystem;

int main()
{
  fs::path p = "/usr/bin/clang";

  std::string s = p.display_string();
  std::print("{}\n", s);
}
  • p.display_string()[color ff0000]

出力

/usr/bin/clang

バージョン

言語

  • C++26

処理系

関連項目

参照