aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-11-23 22:20:00 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-11-23 22:20:00 +0100
commitc9fdf7c17782cc4fa60ae41fb8d8a28ee93f43d5 (patch)
tree07e50f2de6d3bd37b6bedcbc515e19a879235a34 /libs
parentc3e178493607271a4e68c1a1427b3ac82671e72c (diff)
parentc0c6b4a536a825e996fb11f4ae26625253cc0d18 (diff)
downloadkernel-c9fdf7c17782cc4fa60ae41fb8d8a28ee93f43d5.tar.xz
kernel-c9fdf7c17782cc4fa60ae41fb8d8a28ee93f43d5.zip
Merge branch 'fmorgner/pcie-scan' into 'develop'HEADdevelop
dev/pci: implement basic PCI detection See merge request teachos/kernel!74
Diffstat (limited to 'libs')
-rw-r--r--libs/kstd/kstd/bits/observer_ptr.hpp9
-rw-r--r--libs/kstd/kstd/test_support/result.hpp33
2 files changed, 42 insertions, 0 deletions
diff --git a/libs/kstd/kstd/bits/observer_ptr.hpp b/libs/kstd/kstd/bits/observer_ptr.hpp
index 753cfcb7..31162716 100644
--- a/libs/kstd/kstd/bits/observer_ptr.hpp
+++ b/libs/kstd/kstd/bits/observer_ptr.hpp
@@ -118,6 +118,15 @@ namespace kstd
return m_ptr;
}
+ //! Advance the observer pointer by a given offset.
+ //!
+ //! @param offset The number of elements to advance the pointer by.
+ //! @return The advanced observer pointer.
+ constexpr auto friend operator+(observer_ptr const & ptr, std::ptrdiff_t offset) noexcept -> observer_ptr
+ {
+ return observer_ptr{ptr.m_ptr + offset};
+ }
+
//! Compare the observer pointer with another observer pointer.
//!>
//! @param other The other observer pointer to compare with.
diff --git a/libs/kstd/kstd/test_support/result.hpp b/libs/kstd/kstd/test_support/result.hpp
new file mode 100644
index 00000000..7b6d765c
--- /dev/null
+++ b/libs/kstd/kstd/test_support/result.hpp
@@ -0,0 +1,33 @@
+#ifndef KSTD_TEST_SUPPORT_RESULT_HPP
+#define KSTD_TEST_SUPPORT_RESULT_HPP
+
+#include <kstd/result.hpp>
+#include <kstd/test_support/string_makers.hpp>
+
+#include <catch2/catch_test_macros.hpp>
+
+#include <source_location>
+#include <utility>
+
+namespace kstd::tests
+{
+
+ //! Require for a result to be successful.
+ //!
+ //! @param result The result to check.
+ //! @param where The source location to report in case of failure.
+ //! @return The successful value contained in the result.
+ template<typename ResultType>
+ auto require_ok(result<ResultType> result, std::source_location where = std::source_location::current()) -> ResultType
+ {
+ if (!result)
+ {
+ FAIL("expected success at " << where.file_name() << ':' << where.line() << ", got "
+ << error_to_string(result.error()));
+ }
+ return std::move(*result);
+ }
+
+} // namespace kstd::tests
+
+#endif