std::filesystem::path:: relative_path
From cppreference.net
<
cpp
|
filesystem
|
path
C++
std::filesystem::path
| Member types | ||||||||||||||||||||||||||
| Member constants | ||||||||||||||||||||||||||
| Member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Path decomposition | ||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Helper classes | ||||||||||||||||||||||||||
|
path relative_path
(
)
const
;
|
(C++17以降) | |
root-path に対する相対パスを返します。つまり、 * this の root-path 以降のすべての汎用形式コンポーネントで構成されるパス名です。 * this が空のパスである場合、空のパスを返します。
目次 |
パラメータ
(なし)
戻り値
ルートパスからの相対パス。 root path 。
例外
実装定義の例外をスローする可能性があります。
例
このコードを実行
#include <filesystem> #include <iostream> namespace fs = std::filesystem; int main() { fs::path p = fs::current_path(); std::cout << "The current path " << p << " decomposes into:\n" << "root-path " << p.root_path() << '\n' << "relative path " << p.relative_path() << '\n'; }
出力例:
The current path "C:\Users\abcdef\Local Settings\temp" decomposes into: root-path "C:\" relative path "Users\abcdef\Local Settings\temp"
関連項目
|
パスに存在する場合、ルート名を返す
(public member function) |
|
|
パスに存在する場合、ルートディレクトリを返す
(public member function) |
|
|
パスに存在する場合、ルートパスを返す
(public member function) |