aboutsummaryrefslogtreecommitdiff
path: root/libs/kstd
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-07-19 17:54:35 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-07-19 18:32:27 +0200
commit399f38f2ae6481aee9d7b7a3a7ad436b127dd0bd (patch)
treebe441e8a0aa0d1a16bd0293c83b1035b8f63df2c /libs/kstd
parent2e4c3f334e2b7fd0853d0e30138b120964f0c06d (diff)
downloadkernel-399f38f2ae6481aee9d7b7a3a7ad436b127dd0bd.tar.xz
kernel-399f38f2ae6481aee9d7b7a3a7ad436b127dd0bd.zip
kstd: move bitfiled_enum header
Diffstat (limited to 'libs/kstd')
-rw-r--r--libs/kstd/kstd.dox7
-rw-r--r--libs/kstd/kstd/bitfield_enum.hpp (renamed from libs/kstd/kstd/ext/bitfield_enum.hpp)29
2 files changed, 16 insertions, 20 deletions
diff --git a/libs/kstd/kstd.dox b/libs/kstd/kstd.dox
index 5920a3cb..39a2d05e 100644
--- a/libs/kstd/kstd.dox
+++ b/libs/kstd/kstd.dox
@@ -5,10 +5,3 @@
//! freestanding environment, since it relies on operating system support (e.g. memory allocation). The implementations
//! found here, aim to be reasonably close to the specifications found in the C++ language standard (ISO14482).
//! However, some differences exists, for example the lack of exceptions.
-
-//! @namespace kstd::ext
-//! Extensions to the Standard Library.
-//!
-//! This namespace includes custom extensions to what is defined for the C++ Standard Library. These extensions not
-//! portable per-se, since they are not implemented by other Standard Library implementations. Whenever possible,
-//! Standard Library conformant types, functions, etc. should be used throughout the TeachOS codebase.
diff --git a/libs/kstd/kstd/ext/bitfield_enum.hpp b/libs/kstd/kstd/bitfield_enum.hpp
index 80fe9d29..047052e4 100644
--- a/libs/kstd/kstd/ext/bitfield_enum.hpp
+++ b/libs/kstd/kstd/bitfield_enum.hpp
@@ -5,7 +5,7 @@
#include <type_traits>
#include <utility>
-namespace kstd::ext
+namespace kstd
{
template<typename EnumType>
@@ -18,48 +18,51 @@ namespace kstd::ext
template<typename EnumType>
concept bitfield_enum = is_bitfield_enum<EnumType>::value;
-}; // namespace kstd::ext
+}; // namespace kstd
-template<kstd::ext::bitfield_enum EnumType>
+template<kstd::bitfield_enum EnumType>
constexpr auto operator|(EnumType lhs, EnumType rhs) -> EnumType
{
- return std::bit_cast<EnumType>(std::to_underlying(lhs) | std::to_underlying(rhs));
+ return std::bit_cast<EnumType>(
+ static_cast<std::underlying_type_t<EnumType>>(std::to_underlying(lhs) | std::to_underlying(rhs)));
}
-template<kstd::ext::bitfield_enum EnumType>
+template<kstd::bitfield_enum EnumType>
constexpr auto operator|=(EnumType & lhs, EnumType rhs) -> EnumType &
{
return lhs = lhs | rhs;
}
-template<kstd::ext::bitfield_enum EnumType>
+template<kstd::bitfield_enum EnumType>
constexpr auto operator&(EnumType lhs, EnumType rhs) -> EnumType
{
- return std::bit_cast<EnumType>(std::to_underlying(lhs) & std::to_underlying(rhs));
+ return std::bit_cast<EnumType>(
+ static_cast<std::underlying_type_t<EnumType>>(std::to_underlying(lhs) & std::to_underlying(rhs)));
}
-template<kstd::ext::bitfield_enum EnumType>
+template<kstd::bitfield_enum EnumType>
constexpr auto operator&=(EnumType & lhs, EnumType rhs) -> EnumType &
{
return lhs = lhs & rhs;
}
-template<kstd::ext::bitfield_enum EnumType>
+template<kstd::bitfield_enum EnumType>
constexpr auto operator^(EnumType lhs, EnumType rhs) -> EnumType
{
- return std::bit_cast<EnumType>(std::to_underlying(lhs) ^ std::to_underlying(rhs));
+ return std::bit_cast<EnumType>(
+ static_cast<std::underlying_type_t<EnumType>>(std::to_underlying(lhs) ^ std::to_underlying(rhs)));
}
-template<kstd::ext::bitfield_enum EnumType>
+template<kstd::bitfield_enum EnumType>
constexpr auto operator^=(EnumType & lhs, EnumType rhs) -> EnumType &
{
return lhs = lhs ^ rhs;
}
-template<kstd::ext::bitfield_enum EnumType>
+template<kstd::bitfield_enum EnumType>
constexpr auto operator~(EnumType lhs) -> EnumType
{
- return std::bit_cast<EnumType>(~std::to_underlying(lhs));
+ return std::bit_cast<EnumType>(static_cast<std::underlying_type_t<EnumType>>(~std::to_underlying(lhs)));
}
#endif \ No newline at end of file