summaryrefslogtreecommitdiffstats
path: root/libcxx/include/filesystem
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2018-12-21 04:09:01 +0000
committerEric Fiselier <eric@efcs.ca>2018-12-21 04:09:01 +0000
commit49b183a9ecf62bc1b37e53bdddf42e6ea4ce4cd7 (patch)
tree62926809ce6b5b1d56cf4ebd6a1492d6f590f1fc /libcxx/include/filesystem
parent866885e12a2278a77dcb195872730d8b0498e43e (diff)
downloadbcm5719-llvm-49b183a9ecf62bc1b37e53bdddf42e6ea4ce4cd7.tar.gz
bcm5719-llvm-49b183a9ecf62bc1b37e53bdddf42e6ea4ce4cd7.zip
Implement LWG 3065: Make path operators friends.
This prevents things like: using namespace std::filesystem; auto x = L"a/b" == std::string("a/b"); llvm-svn: 349884
Diffstat (limited to 'libcxx/include/filesystem')
-rw-r--r--libcxx/include/filesystem62
1 files changed, 25 insertions, 37 deletions
diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem
index 06a0eb33c4e..af713a06358 100644
--- a/libcxx/include/filesystem
+++ b/libcxx/include/filesystem
@@ -1151,6 +1151,31 @@ public:
return __is;
}
+ friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.compare(__rhs) == 0;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.compare(__rhs) != 0;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.compare(__rhs) < 0;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.compare(__rhs) <= 0;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.compare(__rhs) > 0;
+ }
+ friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept {
+ return __lhs.compare(__rhs) >= 0;
+ }
+
+ friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs,
+ const path& __rhs) {
+ path __result(__lhs);
+ __result /= __rhs;
+ return __result;
+ }
private:
inline _LIBCPP_INLINE_VISIBILITY path&
__assign_view(__string_view const& __s) noexcept {
@@ -1167,43 +1192,6 @@ inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept {
_LIBCPP_FUNC_VIS
size_t hash_value(const path& __p) noexcept;
-inline _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs,
- const path& __rhs) noexcept {
- return __lhs.compare(__rhs) == 0;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs,
- const path& __rhs) noexcept {
- return __lhs.compare(__rhs) != 0;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs,
- const path& __rhs) noexcept {
- return __lhs.compare(__rhs) < 0;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs,
- const path& __rhs) noexcept {
- return __lhs.compare(__rhs) <= 0;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs,
- const path& __rhs) noexcept {
- return __lhs.compare(__rhs) > 0;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs,
- const path& __rhs) noexcept {
- return __lhs.compare(__rhs) >= 0;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs,
- const path& __rhs) {
- path __result(__lhs);
- __result /= __rhs;
- return __result;
-}
-
template <class _Source>
_LIBCPP_INLINE_VISIBILITY
typename enable_if<__is_pathable<_Source>::value, path>::type
OpenPOWER on IntegriCloud