- filesystem[meta header]
- std::filesystem[meta namespace]
- path[meta class]
- function[meta id-type]
- cpp17[meta cpp]
std::u16string generic_u16string() const;
UTF-16エンコードで、環境非依存パスフォーマットのパス文字列を取得する。
*this
が保持するシステムの環境非依存パスフォーマットを持つパスを、UTF-16エンコードで返す。
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
fs::path p = "/usr/bin/clang";
const std::u16string s = p.generic_u16string();
}
- p.generic_u16string()[color ff0000]
#include <cassert>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
fs::path p = "foo\\bar";
const std::u16string s = p.generic_u16string();
assert(s == u"foo/bar");
}
- p.generic_u16string()[color ff0000]
- C++17
- Clang:
- GCC: 8.1
- Visual C++: 2017 Update 7