Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      operator==,!=,<,<=,>,>=,<=>(std::filesystem::path)

      From cppreference.com
      <cpp‎ |filesystem‎ |path
       
       
      Filesystem library
      Classes
      Functions
      File types
       
      std::filesystem::path
      Member types
      Member constants
      Member functions
      Path decomposition
      Non-member functions
      operator==operator!=operator<operator<=operator>operator>=operator<=>
      (until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20)
      Helper classes
       
      friendbool operator==(const path& lhs,const path& rhs)noexcept;
      (1)(since C++17)
      friendbool operator!=(const path& lhs,const path& rhs)noexcept;
      (2)(since C++17)
      (until C++20)
      friendbool operator<(const path& lhs,const path& rhs)noexcept;
      (3)(since C++17)
      (until C++20)
      friendbool operator<=(const path& lhs,const path& rhs)noexcept;
      (4)(since C++17)
      (until C++20)
      friendbool operator>(const path& lhs,const path& rhs)noexcept;
      (5)(since C++17)
      (until C++20)
      friendbool operator>=(const path& lhs,const path& rhs)noexcept;
      (6)(since C++17)
      (until C++20)
      friendstd::strong_ordering
          operator<=>(const path& lhs,const path& rhs)noexcept;
      (7)(since C++20)

      Compares two paths lexicographically.

      1) Checks whetherlhs andrhs are equal. Equivalent to!(lhs< rhs)&&!(rhs< lhs).
      2) Checks whetherlhs andrhs are not equal. Equivalent to!(lhs== rhs).
      3) Checks whetherlhs is less thanrhs. Equivalent tolhs.compare(rhs)<0.
      4) Checks whetherlhs is less than or equal torhs. Equivalent to!(rhs< lhs).
      5) Checks whetherlhs is greater thanrhs. Equivalent torhs< lhs.
      6) Checks whetherlhs is greater than or equal torhs. Equivalent to!(lhs< rhs).
      7) Obtains the three-way comparison result oflhs andrhs. Equivalent tolhs.compare(rhs)<=>0.

      These functions are not visible to ordinaryunqualified orqualified lookup, and can only be found byargument-dependent lookup when std::filesystem::path is an associated class of the arguments. This prevents undesirable conversions in the presence of ausingnamespace std::filesystem;using-directive.

      The<,<=,>,>=, and!= operators aresynthesized fromoperator<=> andoperator== respectively.

      (since C++20)

      Contents

      [edit]Parameters

      lhs, rhs - the paths to compare

      [edit]Return value

      1-6)true if the corresponding comparison yields,false otherwise.
      7)std::strong_ordering::less iflhs is less thanrhs, otherwisestd::strong_ordering::greater ifrhs is less thanlhs, otherwisestd::strong_ordering::equal.

      [edit]Notes

      Path equality and equivalence have different semantics.

      In the case of equality, as determined byoperator==, only lexical representations are compared. Therefore,path("a")== path("b") is nevertrue.

      In the case of equivalence, as determined bystd::filesystem::equivalent(), it is checked whether two pathsresolve to the same file system object. Thusequivalent("a","b") will returntrue if the paths resolve to the same file.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 3065C++17allowed comparison of everything convertible topath in the presence of ausing-directivemade hidden friend

      [edit]See also

      compares the lexical representations of two paths lexicographically
      (public member function)[edit]
      (C++17)
      checks whether two paths refer to the same file system object
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/filesystem/path/operator_cmp&oldid=156796"

      [8]ページ先頭

      ©2009-2025 Movatter.jp