diff options
| -rw-r--r-- | kernel/src/filesystem/mount_table.cpp | 3 | ||||
| -rw-r--r-- | libs/kstd/include/kstd/bits/shared_ptr.hpp | 29 |
2 files changed, 25 insertions, 7 deletions
diff --git a/kernel/src/filesystem/mount_table.cpp b/kernel/src/filesystem/mount_table.cpp index b4a906b..3176d6d 100644 --- a/kernel/src/filesystem/mount_table.cpp +++ b/kernel/src/filesystem/mount_table.cpp @@ -18,8 +18,7 @@ namespace filesystem auto mount_table::find_mount_by_dentry(kstd::shared_ptr<dentry> const & dentry) -> kstd::shared_ptr<mount> { - auto it = - std::ranges::find_if(m_mounts, [&](auto const & mount) { return mount->get_dentry().get() == dentry.get(); }); + auto it = std::ranges::find_if(m_mounts, [&](auto const & mount) { return mount->get_dentry() == dentry; }); if (it != m_mounts.end()) { return *it; diff --git a/libs/kstd/include/kstd/bits/shared_ptr.hpp b/libs/kstd/include/kstd/bits/shared_ptr.hpp index 674807d..8930095 100644 --- a/libs/kstd/include/kstd/bits/shared_ptr.hpp +++ b/libs/kstd/include/kstd/bits/shared_ptr.hpp @@ -546,11 +546,6 @@ namespace kstd return ptr.pointer == nullptr; } - /** - * @brief Defaulted three-way comparator operator. - */ - [[nodiscard]] auto operator<=>(shared_ptr const & other) const = default; - private: /** * @brief If the candidate type inherits from enable_shared_from_this, assigns the internal weak pointer to this @@ -624,6 +619,30 @@ namespace kstd { return shared_ptr<T>(new T(std::forward<Args>(args)...)); } + + /** + * @brief Equality operator for shared_ptr. Two shared_ptr instances are equal if they point to the same object + * @tparam T, U Types of the managed objects of the shared_ptr instances being compared. + * @param lhs, rhs The shared_ptr instances to compare. + * @return true if lhs and rhs point to the same object, false otherwise. + */ + template<typename T, typename U> + [[nodiscard]] auto inline operator==(shared_ptr<T> const & lhs, shared_ptr<U> const & rhs) -> bool + { + return lhs.get() == rhs.get(); + } + + /** + * @brief Three-way comparison operator for shared_ptr. Compares the stored pointers of lhs and rhs using operator<=>. + * @tparam T, U Types of the managed objects of the shared_ptr instances being compared. + * @param lhs, rhs The shared_ptr instances to compare. + * @return The result of comparing the stored pointers of lhs and rhs using operator<=> + */ + template<typename T, typename U> + [[nodiscard]] auto inline operator<=>(shared_ptr<T> const & lhs, shared_ptr<U> const & rhs) + { + return lhs.get() <=> rhs.get(); + } } // namespace kstd #endif
\ No newline at end of file |
