From 1ab4ace23cd30f1be5894764ac335f5a2073f628 Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Fri, 15 Nov 2024 01:34:34 +0200 Subject: [PATCH] stl: Update headers type_traits: Add is_integral optional: Add stub optional class iterator: Add default_sentinel_t & default_sentinel concepts: Add concepts header + integral concept --- include_std/concepts | 26 ++++++++++++++++++++++++++ include_std/iterator | 6 ++++++ include_std/optional | 26 ++++++++++++++++++++++++++ include_std/type_traits | 11 +++++++++++ 4 files changed, 69 insertions(+) create mode 100644 include_std/concepts create mode 100644 include_std/optional diff --git a/include_std/concepts b/include_std/concepts new file mode 100644 index 0000000..fd44001 --- /dev/null +++ b/include_std/concepts @@ -0,0 +1,26 @@ +/* + This file is part of Fennix Kernel. + + Fennix Kernel is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + Fennix Kernel is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Fennix Kernel. If not, see . +*/ + +#pragma once + +#include + +namespace std +{ + template + concept integral = std::is_integral_v; +} diff --git a/include_std/iterator b/include_std/iterator index a10e5bf..22136cf 100644 --- a/include_std/iterator +++ b/include_std/iterator @@ -129,4 +129,10 @@ namespace std std::advance(it, n); return it; } + + struct default_sentinel_t + { + }; + + inline constexpr default_sentinel_t default_sentinel{}; } diff --git a/include_std/optional b/include_std/optional new file mode 100644 index 0000000..c05bf17 --- /dev/null +++ b/include_std/optional @@ -0,0 +1,26 @@ +/* + This file is part of Fennix Kernel. + + Fennix Kernel is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + Fennix Kernel is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Fennix Kernel. If not, see . +*/ + +#pragma once + +#include + +namespace std +{ + template + class optional; +} diff --git a/include_std/type_traits b/include_std/type_traits index 7f833d5..5508a9f 100644 --- a/include_std/type_traits +++ b/include_std/type_traits @@ -284,6 +284,17 @@ namespace std template using bool_constant = integral_constant; + template + struct is_integral : bool_constant < requires(T t, T *p, void (*f)(T)) + { + reinterpret_cast(t); + f(0); + p + t; + } > {}; + + template + constexpr bool is_integral_v = is_integral::value; + typedef integral_constant true_type; typedef integral_constant false_type;