From fcbbbfc479a2aab86f88c783e5e66e7cfee39e84 Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Mon, 30 Mar 2026 22:02:30 -0700 Subject: [PATCH 1/4] Change bits/ include path Use "bits/xxx.h" not "frozen/bits/xxx.h" -- that way the host can set their include path to "include/frozen" rather than "include". --- include/frozen/algorithm.h | 6 +++--- include/frozen/bits/algorithms.h | 2 +- include/frozen/bits/basic_types.h | 4 ++-- include/frozen/bits/pmh.h | 4 ++-- include/frozen/map.h | 10 +++++----- include/frozen/random.h | 4 ++-- include/frozen/set.h | 5 ++--- include/frozen/string.h | 10 +++++++++- include/frozen/unordered_map.h | 12 +++++------- include/frozen/unordered_set.h | 10 +++++----- 10 files changed, 36 insertions(+), 31 deletions(-) diff --git a/include/frozen/algorithm.h b/include/frozen/algorithm.h index a538f7c..4238367 100644 --- a/include/frozen/algorithm.h +++ b/include/frozen/algorithm.h @@ -32,9 +32,9 @@ #error "frozen/algorithm.h requires C++23 or later. Compile with -std=c++23 or later." #endif -#include "frozen/bits/basic_types.h" -#include "frozen/bits/version.h" -#include "frozen/string.h" +#include "bits/basic_types.h" +#include "bits/version.h" +#include "string.h" namespace frozen { diff --git a/include/frozen/bits/algorithms.h b/include/frozen/bits/algorithms.h index 310c31d..fc792f6 100644 --- a/include/frozen/bits/algorithms.h +++ b/include/frozen/bits/algorithms.h @@ -22,7 +22,7 @@ #pragma once -#include "frozen/bits/basic_types.h" +#include "basic_types.h" #include #include diff --git a/include/frozen/bits/basic_types.h b/include/frozen/bits/basic_types.h index 817908f..336229e 100644 --- a/include/frozen/bits/basic_types.h +++ b/include/frozen/bits/basic_types.h @@ -22,8 +22,8 @@ #pragma once -#include "frozen/bits/constexpr_assert.h" -#include "frozen/bits/exceptions.h" +#include "constexpr_assert.h" +#include "exceptions.h" #include #include diff --git a/include/frozen/bits/pmh.h b/include/frozen/bits/pmh.h index 7591886..16f6d26 100644 --- a/include/frozen/bits/pmh.h +++ b/include/frozen/bits/pmh.h @@ -23,8 +23,8 @@ // inspired from http://stevehanov.ca/blog/index.php?id=119 #pragma once -#include "frozen/bits/algorithms.h" -#include "frozen/bits/basic_types.h" +#include "algorithms.h" +#include "basic_types.h" #include #include diff --git a/include/frozen/map.h b/include/frozen/map.h index 733b51a..0dc8b81 100644 --- a/include/frozen/map.h +++ b/include/frozen/map.h @@ -31,11 +31,11 @@ #error "frozen/map.h requires C++23 or later. Compile with -std=c++23 or later." #endif -#include "frozen/bits/algorithms.h" -#include "frozen/bits/basic_types.h" -#include "frozen/bits/exceptions.h" -#include "frozen/bits/mpl.h" -#include "frozen/bits/version.h" +#include "bits/algorithms.h" +#include "bits/basic_types.h" +#include "bits/exceptions.h" +#include "bits/mpl.h" +#include "bits/version.h" #include #include diff --git a/include/frozen/random.h b/include/frozen/random.h index 1d41232..c6db3bd 100644 --- a/include/frozen/random.h +++ b/include/frozen/random.h @@ -31,8 +31,8 @@ #error "frozen/random.h requires C++23 or later. Compile with -std=c++23 or later." #endif -#include "frozen/bits/algorithms.h" -#include "frozen/bits/version.h" +#include "bits/algorithms.h" +#include "bits/version.h" #include #include diff --git a/include/frozen/set.h b/include/frozen/set.h index 2ee4195..45552d5 100644 --- a/include/frozen/set.h +++ b/include/frozen/set.h @@ -31,9 +31,8 @@ #error "frozen/set.h requires C++23 or later. Compile with -std=c++23 or later." #endif -#include "frozen/bits/algorithms.h" -#include "frozen/bits/basic_types.h" -#include "frozen/bits/version.h" +#include "bits/algorithms.h" +#include "bits/basic_types.h" #include #include diff --git a/include/frozen/string.h b/include/frozen/string.h index 71ad52d..dc4cf90 100644 --- a/include/frozen/string.h +++ b/include/frozen/string.h @@ -1,6 +1,14 @@ #pragma once -#include "frozen/bits/version.h" +// Require C++23 or later +#if defined(_MSVC_LANG) + #if _MSVC_LANG < 202302L + #error \ + "frozen/unordered_map.h requires C++23 or later. Compile with /std:c++latest or /std:c++23." + #endif +#elif __cplusplus < 202302L + #error "frozen/unordered_map.h requires C++23 or later. Compile with -std=c++23 or later." +#endif #include #include diff --git a/include/frozen/unordered_map.h b/include/frozen/unordered_map.h index cacea20..56d888d 100644 --- a/include/frozen/unordered_map.h +++ b/include/frozen/unordered_map.h @@ -32,15 +32,13 @@ #error "frozen/unordered_map.h requires C++23 or later. Compile with -std=c++23 or later." #endif -#include "frozen/bits/basic_types.h" -#include "frozen/bits/elsa.h" -#include "frozen/bits/exceptions.h" -#include "frozen/bits/pmh.h" -#include "frozen/bits/version.h" -#include "frozen/random.h" +#include "bits/basic_types.h" +#include "bits/elsa.h" +#include "bits/exceptions.h" +#include "bits/pmh.h" +#include "random.h" #include -#include #include namespace frozen diff --git a/include/frozen/unordered_set.h b/include/frozen/unordered_set.h index 4d19112..2385518 100644 --- a/include/frozen/unordered_set.h +++ b/include/frozen/unordered_set.h @@ -32,11 +32,11 @@ #error "frozen/unordered_set.h requires C++23 or later. Compile with -std=c++23 or later." #endif -#include "frozen/bits/basic_types.h" -#include "frozen/bits/elsa.h" -#include "frozen/bits/pmh.h" -#include "frozen/bits/version.h" -#include "frozen/random.h" +#include "bits/basic_types.h" +#include "bits/elsa.h" +#include "bits/pmh.h" +#include "bits/version.h" +#include "random.h" #include #include From a65469e2a133fc4fbfa21bbebf515b94c1ccb687 Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Fri, 3 Apr 2026 08:32:55 -0700 Subject: [PATCH 2/4] Remove unused header files --- include/frozen/algorithm.h | 2 -- include/frozen/map.h | 1 - include/frozen/random.h | 1 - 3 files changed, 4 deletions(-) diff --git a/include/frozen/algorithm.h b/include/frozen/algorithm.h index 4238367..6b92bac 100644 --- a/include/frozen/algorithm.h +++ b/include/frozen/algorithm.h @@ -33,8 +33,6 @@ #endif #include "bits/basic_types.h" -#include "bits/version.h" -#include "string.h" namespace frozen { diff --git a/include/frozen/map.h b/include/frozen/map.h index 0dc8b81..73260f6 100644 --- a/include/frozen/map.h +++ b/include/frozen/map.h @@ -35,7 +35,6 @@ #include "bits/basic_types.h" #include "bits/exceptions.h" #include "bits/mpl.h" -#include "bits/version.h" #include #include diff --git a/include/frozen/random.h b/include/frozen/random.h index c6db3bd..88e2df5 100644 --- a/include/frozen/random.h +++ b/include/frozen/random.h @@ -32,7 +32,6 @@ #endif #include "bits/algorithms.h" -#include "bits/version.h" #include #include From 26a89038845cff8324a8846c6b8e427b02cd32ec Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Fri, 3 Apr 2026 08:33:41 -0700 Subject: [PATCH 3/4] Refactor/cleanup --- include/frozen/set.h | 20 +++++---- include/frozen/unordered_set.h | 77 ++++++++++++++++++---------------- 2 files changed, 53 insertions(+), 44 deletions(-) diff --git a/include/frozen/set.h b/include/frozen/set.h index 45552d5..a79b300 100644 --- a/include/frozen/set.h +++ b/include/frozen/set.h @@ -100,9 +100,10 @@ namespace frozen { const_iterator where = lower_bound(key); if ((where != end()) && !value_comp()(key, *where)) + { return where; - else - return end(); + } + return end(); } template @@ -117,9 +118,10 @@ namespace frozen { auto const lower = lower_bound(key); if (lower == end()) + { return { lower, lower }; - else - return { lower, lower + 1 }; + } + return { lower, lower + 1 }; } template @@ -127,9 +129,10 @@ namespace frozen { auto const where = bits::lower_bound(keys_.begin(), key, value_comp()); if ((where != end()) && !value_comp()(key, *where)) + { return where; - else - return end(); + } + return end(); } template @@ -137,9 +140,10 @@ namespace frozen { auto const where = bits::lower_bound(keys_.begin(), key, value_comp()); if ((where != end()) && !value_comp()(key, *where)) + { return where + 1; - else - return end(); + } + return end(); } /* observers */ diff --git a/include/frozen/unordered_set.h b/include/frozen/unordered_set.h index 2385518..e38fcc8 100644 --- a/include/frozen/unordered_set.h +++ b/include/frozen/unordered_set.h @@ -35,7 +35,6 @@ #include "bits/basic_types.h" #include "bits/elsa.h" #include "bits/pmh.h" -#include "bits/version.h" #include "random.h" #include @@ -50,7 +49,7 @@ namespace frozen struct Get { template - constexpr T const& operator()(T const& key) const + constexpr auto operator()(T const& key) const -> T const& { return key; } @@ -85,7 +84,6 @@ namespace frozen using const_iterator = typename container_type::const_iterator; using iterator = const_iterator; - public: /* constructors */ unordered_set(unordered_set const&) = default; constexpr unordered_set(container_type keys, Hash const& hash, KeyEqual const& equal) : @@ -111,72 +109,79 @@ namespace frozen } /* iterators */ - [[nodiscard]] constexpr const_iterator begin() const { return keys_.begin(); } - [[nodiscard]] constexpr const_iterator end() const { return keys_.end(); } - [[nodiscard]] constexpr const_iterator cbegin() const { return keys_.begin(); } - [[nodiscard]] constexpr const_iterator cend() const { return keys_.end(); } + [[nodiscard]] constexpr auto begin() const -> const_iterator { return keys_.begin(); } + [[nodiscard]] constexpr auto end() const -> const_iterator { return keys_.end(); } + [[nodiscard]] constexpr auto cbegin() const -> const_iterator { return keys_.begin(); } + [[nodiscard]] constexpr auto cend() const -> const_iterator { return keys_.end(); } /* capacity */ - [[nodiscard]] constexpr bool empty() const { return !N; } - [[nodiscard]] constexpr size_type size() const { return N; } - [[nodiscard]] constexpr size_type max_size() const { return N; } + [[nodiscard]] constexpr auto empty() const -> bool { return !N; } + [[nodiscard]] constexpr auto size() const -> size_type { return N; } + [[nodiscard]] constexpr auto max_size() const -> size_type { return N; } /* lookup */ template - [[nodiscard]] constexpr std::size_t count(KeyType const& key) const + [[nodiscard]] constexpr auto count(KeyType const& key) const -> std::size_t { return find(key, hash_function(), key_eq()) != end(); } template - [[nodiscard]] constexpr const_iterator find(KeyType const& key, Hasher const& hash, - Equal const& equal) const + [[nodiscard]] constexpr auto find(KeyType const& key, Hasher const& hash, + Equal const& equal) const -> const_iterator { auto const pos = tables_.lookup(key, hash); - auto it = keys_.begin() + pos; - if (it != keys_.end() && equal(*it, key)) - return it; - else - return keys_.end(); + auto iter = keys_.begin() + pos; + if (iter != keys_.end() && equal(*iter, key)) + { + return iter; + } + return keys_.end(); } + template - [[nodiscard]] constexpr const_iterator find(KeyType const& key) const + [[nodiscard]] constexpr auto find(KeyType const& key) const -> const_iterator { auto const pos = tables_.lookup(key, hash_function()); - auto it = keys_.begin() + pos; - if (it != keys_.end() && key_eq()(*it, key)) - return it; - else - return keys_.end(); + auto iter = keys_.begin() + pos; + if (iter != keys_.end() && key_eq()(*iter, key)) + { + return iter; + } + return keys_.end(); } template - [[nodiscard]] constexpr bool contains(KeyType const& key) const + [[nodiscard]] constexpr auto contains(KeyType const& key) const -> bool { return this->find(key) != keys_.end(); } template - [[nodiscard]] constexpr std::pair - equal_range(KeyType const& key) const + [[nodiscard]] constexpr auto equal_range(KeyType const& key) const + -> std::pair { - auto const it = find(key); - if (it != end()) - return { it, it + 1 }; - else - return { keys_.end(), keys_.end() }; + auto const iter = find(key); + if (iter != end()) + { + return { iter, iter + 1 }; + } + return { keys_.end(), keys_.end() }; } /* bucket interface */ - [[nodiscard]] constexpr std::size_t bucket_count() const { return storage_size; } - [[nodiscard]] constexpr std::size_t max_bucket_count() const { return storage_size; } + [[nodiscard]] constexpr auto bucket_count() const -> std::size_t { return storage_size; } + [[nodiscard]] constexpr auto max_bucket_count() const -> std::size_t + { + return storage_size; + } /* observers*/ - [[nodiscard]] constexpr const hasher& hash_function() const + [[nodiscard]] constexpr auto hash_function() const -> const hasher& { return tables_.hash_function(); } - [[nodiscard]] constexpr const key_equal& key_eq() const + [[nodiscard]] constexpr auto key_eq() const -> const key_equal& { return static_cast(*this); } From d0b70b1d8935d190055641ac1bcf33072ec0169b Mon Sep 17 00:00:00 2001 From: Randalphwa <38287198+Randalphwa@users.noreply.github.com> Date: Fri, 3 Apr 2026 08:38:36 -0700 Subject: [PATCH 4/4] Allow draft versions of C++23 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 202302L is the final C++23 value. Apple Clang (even when compiling with -std=c++23 or -std=c++2b) sets __cplusplus to a draft value like 202101L or 202302L depending on the Clang version. Older Apple Clang versions that ship with macOS (which lag significantly behind upstream LLVM) commonly report 202101L — a C++23 draft value — rather than the ratified 202302L. --- include/frozen/algorithm.h | 2 +- include/frozen/bits/version.h | 2 +- include/frozen/map.h | 2 +- include/frozen/random.h | 2 +- include/frozen/set.h | 2 +- include/frozen/string.h | 2 +- include/frozen/unordered_map.h | 2 +- include/frozen/unordered_set.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/frozen/algorithm.h b/include/frozen/algorithm.h index 6b92bac..7e02c5a 100644 --- a/include/frozen/algorithm.h +++ b/include/frozen/algorithm.h @@ -28,7 +28,7 @@ #error \ "frozen/algorithm.h requires C++23 or later. Compile with /std:c++latest or /std:c++23." #endif -#elif __cplusplus < 202302L +#elif __cplusplus < 202101L #error "frozen/algorithm.h requires C++23 or later. Compile with -std=c++23 or later." #endif diff --git a/include/frozen/bits/version.h b/include/frozen/bits/version.h index a6278df..0d1e83f 100644 --- a/include/frozen/bits/version.h +++ b/include/frozen/bits/version.h @@ -27,7 +27,7 @@ #if _MSVC_LANG < 202302L #error "frozen 2.0 requires C++23 or later. Compile with /std:c++latest or /std:c++23." #endif -#elif __cplusplus < 202302L +#elif __cplusplus < 202101L #error "frozen 2.0 requires C++23 or later. Compile with -std=c++23 or later." #endif diff --git a/include/frozen/map.h b/include/frozen/map.h index 73260f6..74dbcae 100644 --- a/include/frozen/map.h +++ b/include/frozen/map.h @@ -27,7 +27,7 @@ #if _MSVC_LANG < 202302L #error "frozen/map.h requires C++23 or later. Compile with /std:c++latest or /std:c++23." #endif -#elif __cplusplus < 202302L +#elif __cplusplus < 202101L #error "frozen/map.h requires C++23 or later. Compile with -std=c++23 or later." #endif diff --git a/include/frozen/random.h b/include/frozen/random.h index 88e2df5..3c3681c 100644 --- a/include/frozen/random.h +++ b/include/frozen/random.h @@ -27,7 +27,7 @@ #if _MSVC_LANG < 202302L #error "frozen/random.h requires C++23 or later. Compile with /std:c++latest or /std:c++23." #endif -#elif __cplusplus < 202302L +#elif __cplusplus < 202101L #error "frozen/random.h requires C++23 or later. Compile with -std=c++23 or later." #endif diff --git a/include/frozen/set.h b/include/frozen/set.h index a79b300..dee8f0e 100644 --- a/include/frozen/set.h +++ b/include/frozen/set.h @@ -27,7 +27,7 @@ #if _MSVC_LANG < 202302L #error "frozen/set.h requires C++23 or later. Compile with /std:c++latest or /std:c++23." #endif -#elif __cplusplus < 202302L +#elif __cplusplus < 202101L #error "frozen/set.h requires C++23 or later. Compile with -std=c++23 or later." #endif diff --git a/include/frozen/string.h b/include/frozen/string.h index dc4cf90..ff2d85b 100644 --- a/include/frozen/string.h +++ b/include/frozen/string.h @@ -6,7 +6,7 @@ #error \ "frozen/unordered_map.h requires C++23 or later. Compile with /std:c++latest or /std:c++23." #endif -#elif __cplusplus < 202302L +#elif __cplusplus < 202101L #error "frozen/unordered_map.h requires C++23 or later. Compile with -std=c++23 or later." #endif diff --git a/include/frozen/unordered_map.h b/include/frozen/unordered_map.h index 56d888d..13e33e1 100644 --- a/include/frozen/unordered_map.h +++ b/include/frozen/unordered_map.h @@ -28,7 +28,7 @@ #error \ "frozen/unordered_map.h requires C++23 or later. Compile with /std:c++latest or /std:c++23." #endif -#elif __cplusplus < 202302L +#elif __cplusplus < 202101L #error "frozen/unordered_map.h requires C++23 or later. Compile with -std=c++23 or later." #endif diff --git a/include/frozen/unordered_set.h b/include/frozen/unordered_set.h index e38fcc8..c0e151a 100644 --- a/include/frozen/unordered_set.h +++ b/include/frozen/unordered_set.h @@ -28,7 +28,7 @@ #error \ "frozen/unordered_set.h requires C++23 or later. Compile with /std:c++latest or /std:c++23." #endif -#elif __cplusplus < 202302L +#elif __cplusplus < 202101L #error "frozen/unordered_set.h requires C++23 or later. Compile with -std=c++23 or later." #endif