名前空間
変種
操作

std::filesystem::path::replace_filename

提供: cppreference.com
< cpp‎ | filesystem‎ | path
 
 
 
 
path& replace_filename(const path& replacement );
(C++17以上)

単一のファイル名部分を replacement で置き換えます。

以下と同等です。

remove_filename(); operator/=(replacement);

パスがファイル名部分を持たない (has_filenamefalse を返す) 場合、動作は未定義です。

目次

[編集]引数

(なし)

[編集]戻り値

*this

[編集]例外

(なし)

[編集]

#include <iostream>#include <filesystem>namespace fs = std::filesystem;   int main(){   std::cout<< fs::path("/foo").replace_filename("bar")<<'\n'<< fs::path("/").replace_filename("bar")<<'\n';}

出力:

"/bar" "bar"

[編集]関連項目

拡張子を置換します
(パブリックメンバ関数)[edit]
パスのファイル名部分を返します
(パブリックメンバ関数)[edit]
パスのファイル名部分を削除します
(パブリックメンバ関数)[edit]
対応するパス要素が空でないかどうか調べます
(パブリックメンバ関数)
close