[fs.path.compare] # 31 Input/output library [[input.output]](./#input.output) ## 31.12 File systems [[filesystems]](filesystems#fs.path.compare) ### 31.12.6 Class path [[fs.class.path]](fs.class.path#fs.path.compare) #### 31.12.6.5 Members [[fs.path.member]](fs.path.member#fs.path.compare) #### 31.12.6.5.8 Compare [fs.path.compare] [🔗](#lib:compare,path) `int compare(const path& p) const noexcept; ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14805) *Returns*: - [(1.1)](#1.1) Let rootNameComparison be the result of this->root_name().native().compare(p.root_name().native())[.](#1.1.sentence-1) If rootNameComparison is not 0, rootNameComparison[.](#1.1.sentence-2) - [(1.2)](#1.2) Otherwise, if !this->has_root_directory() and p.has_root_directory(), a value less than 0[.](#1.2.sentence-1) - [(1.3)](#1.3) Otherwise, if this->has_root_directory() and !p.has_root_directory(), a value greater than 0[.](#1.3.sentence-1) - [(1.4)](#1.4) Otherwise, if native() for the elements of this->relative_path() are lexicographically less than native() for the elements of p.relative_path(), a value less than 0[.](#1.4.sentence-1) - [(1.5)](#1.5) Otherwise, if native() for the elements of this->relative_path() are lexicographically greater than native() for the elements of p.relative_path(), a value greater than 0[.](#1.5.sentence-1) - [(1.6)](#1.6) Otherwise, 0[.](#1.6.sentence-1) [🔗](#lib:compare,path_) `int compare(const string_type& s) const; int compare(basic_string_view s) const; int compare(const value_type* s) const; ` [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L14846) *Effects*: Equivalent to: return compare(path(s));