std::filesystem:: operator/ (std::filesystem::path)
| Member types | ||||||||||||||||||||||||||
| Member constants | ||||||||||||||||||||||||||
| Member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Path decomposition | ||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| Helper classes | ||||||||||||||||||||||||||
|
friend
path operator
/
(
const
path
&
lhs,
const
path
&
rhs
)
;
|
(C++17以降) | |
適切な場合に推奨されるディレクトリ区切り文字を使用して2つのパスコンポーネントを連結します(詳細は operator/= を参照してください)。
実質的に path ( lhs ) / = rhs を返します。
この関数は通常の unqualified lookup または qualified lookup では可視化されず、引数の関連クラスとしてstd::filesystem::pathが含まれている場合にのみ argument-dependent lookup によって発見されます。これは using namespace std :: filesystem ; using-directive が存在する場合の望ましくない変換を防止します。
目次 |
パラメータ
| lhs, rhs | - | 連結するパス |
戻り値
パスの連結結果。
例
#include <filesystem> #include <iostream> int main() { # if defined(_WIN32) // see e.g. stackoverflow.com/questions/142508 std::filesystem::path p = "C:"; std::cout << R"("C:\" / "Users" / "batman" == )" << p / "Users" / "batman" << '\n'; # else // __linux__ etc std::filesystem::path p = "/home"; std::cout << R"("/home" / "tux" / ".fonts" ==)" << p / "tux" / ".fonts" << '\n'; # endif }
出力例:
Windows固有の出力: "C:" / "Users" / "batman" == "C:Users\\batman" Linuxなど固有の出力: "/home" / "tux" / ".fonts" == "/home/tux/.fonts"
不具合報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 3065 | C++17 |
using-directive
が存在する場合、
path
に変換可能なすべての連結を許可していた
|
非公開フレンド関数に変更 |
関連項目
|
ディレクトリ区切り文字を使用してパスに要素を追加する
(公開メンバー関数) |