From 01580777f6710da0318cacf5f86e9c684df376fb Mon Sep 17 00:00:00 2001 From: Firat Hajiyev Date: Thu, 15 Oct 2026 20:06:24 -0400 Subject: [PATCH] Fix chrono comparisons in no-STL builds --- include/etl/private/chrono/day.h | 2 +- include/etl/private/chrono/duration.h | 2 +- include/etl/private/chrono/month.h | 2 +- include/etl/private/chrono/month_day.h | 4 +-- include/etl/private/chrono/time_point.h | 2 +- include/etl/private/chrono/year.h | 2 +- include/etl/private/chrono/year_month.h | 2 +- include/etl/private/chrono/year_month_day.h | 4 +-- test/syntax_check/CMakeLists.txt | 1 + test/syntax_check/chrono_no_stl.h.t.cpp | 32 +++++++++++++++++++++ 10 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 test/syntax_check/chrono_no_stl.h.t.cpp diff --git a/include/etl/private/chrono/day.h b/include/etl/private/chrono/day.h index a929c601..1f903067 100644 --- a/include/etl/private/chrono/day.h +++ b/include/etl/private/chrono/day.h @@ -211,7 +211,7 @@ namespace etl //*********************************************************************** /// Spaceship operator //*********************************************************************** -#if ETL_USING_CPP20 +#if ETL_USING_CPP20 && ETL_USING_STL [[nodiscard]] inline constexpr auto operator<=>(const etl::chrono::day& d1, const etl::chrono::day& d2) ETL_NOEXCEPT { diff --git a/include/etl/private/chrono/duration.h b/include/etl/private/chrono/duration.h index bc8d6ba5..cf48e170 100644 --- a/include/etl/private/chrono/duration.h +++ b/include/etl/private/chrono/duration.h @@ -482,7 +482,7 @@ namespace etl //*********************************************************************** /// Spaceship operator //*********************************************************************** -#if ETL_USING_CPP20 +#if ETL_USING_CPP20 && ETL_USING_STL template [[nodiscard]] constexpr auto operator<=>(const etl::chrono::duration& lhs, const etl::chrono::duration& rhs) ETL_NOEXCEPT diff --git a/include/etl/private/chrono/month.h b/include/etl/private/chrono/month.h index 662bb632..40c2e594 100644 --- a/include/etl/private/chrono/month.h +++ b/include/etl/private/chrono/month.h @@ -224,7 +224,7 @@ namespace etl //*********************************************************************** /// Spaceship operator //*********************************************************************** -#if ETL_USING_CPP20 +#if ETL_USING_CPP20 && ETL_USING_STL [[nodiscard]] inline constexpr auto operator<=>(const etl::chrono::month& d1, const etl::chrono::month& d2) ETL_NOEXCEPT { diff --git a/include/etl/private/chrono/month_day.h b/include/etl/private/chrono/month_day.h index dcefbff6..f4f77628 100644 --- a/include/etl/private/chrono/month_day.h +++ b/include/etl/private/chrono/month_day.h @@ -178,7 +178,7 @@ namespace etl //*********************************************************************** /// Spaceship operator //*********************************************************************** -#if ETL_USING_CPP20 +#if ETL_USING_CPP20 && ETL_USING_STL [[nodiscard]] inline constexpr auto operator<=>(const etl::chrono::month_day& lhs, const etl::chrono::month_day& rhs) ETL_NOEXCEPT { @@ -298,7 +298,7 @@ namespace etl //*********************************************************************** /// Spaceship operator //*********************************************************************** -#if ETL_USING_CPP20 +#if ETL_USING_CPP20 && ETL_USING_STL [[nodiscard]] inline constexpr auto operator<=>(const etl::chrono::month_day_last& mdl1, const etl::chrono::month_day_last& mdl2) ETL_NOEXCEPT { diff --git a/include/etl/private/chrono/time_point.h b/include/etl/private/chrono/time_point.h index f90f1c61..a0e79bb1 100644 --- a/include/etl/private/chrono/time_point.h +++ b/include/etl/private/chrono/time_point.h @@ -353,7 +353,7 @@ namespace etl //*********************************************************************** /// Spaceship operator //*********************************************************************** -#if ETL_USING_CPP20 +#if ETL_USING_CPP20 && ETL_USING_STL template [[nodiscard]] constexpr auto operator<=>(const etl::chrono::time_point& lhs, const etl::chrono::time_point& rhs) diff --git a/include/etl/private/chrono/year.h b/include/etl/private/chrono/year.h index 49ad3530..e6cb3416 100644 --- a/include/etl/private/chrono/year.h +++ b/include/etl/private/chrono/year.h @@ -240,7 +240,7 @@ namespace etl //*********************************************************************** /// Spaceship operator //*********************************************************************** -#if ETL_USING_CPP20 +#if ETL_USING_CPP20 && ETL_USING_STL [[nodiscard]] inline constexpr auto operator<=>(const etl::chrono::year& y1, const etl::chrono::year& y2) ETL_NOEXCEPT { diff --git a/include/etl/private/chrono/year_month.h b/include/etl/private/chrono/year_month.h index 16b3a431..44bb9fd1 100644 --- a/include/etl/private/chrono/year_month.h +++ b/include/etl/private/chrono/year_month.h @@ -234,7 +234,7 @@ namespace etl //*********************************************************************** /// Spaceship operator //*********************************************************************** -#if ETL_USING_CPP20 +#if ETL_USING_CPP20 && ETL_USING_STL [[nodiscard]] inline constexpr auto operator<=>(const etl::chrono::year_month& lhs, const etl::chrono::year_month& rhs) ETL_NOEXCEPT { diff --git a/include/etl/private/chrono/year_month_day.h b/include/etl/private/chrono/year_month_day.h index a0f42474..91088c3b 100644 --- a/include/etl/private/chrono/year_month_day.h +++ b/include/etl/private/chrono/year_month_day.h @@ -426,7 +426,7 @@ namespace etl //*********************************************************************** /// Spaceship operator //*********************************************************************** -#if ETL_USING_CPP20 +#if ETL_USING_CPP20 && ETL_USING_STL [[nodiscard]] inline constexpr auto operator<=>(const etl::chrono::year_month_day& lhs, const etl::chrono::year_month_day& rhs) ETL_NOEXCEPT { @@ -722,7 +722,7 @@ namespace etl //*********************************************************************** /// Spaceship operator //*********************************************************************** -#if ETL_USING_CPP20 +#if ETL_USING_CPP20 && ETL_USING_STL [[nodiscard]] inline constexpr auto operator<=>(const etl::chrono::year_month_day_last& lhs, const etl::chrono::year_month_day_last& rhs) ETL_NOEXCEPT { diff --git a/test/syntax_check/CMakeLists.txt b/test/syntax_check/CMakeLists.txt index 3c4e8e54..d8ee71d9 100644 --- a/test/syntax_check/CMakeLists.txt +++ b/test/syntax_check/CMakeLists.txt @@ -134,6 +134,7 @@ target_sources(tests PRIVATE char_traits.h.t.cpp checksum.h.t.cpp chrono.h.t.cpp + chrono_no_stl.h.t.cpp concepts.h.t.cpp const_map.h.t.cpp const_multimap.h.t.cpp diff --git a/test/syntax_check/chrono_no_stl.h.t.cpp b/test/syntax_check/chrono_no_stl.h.t.cpp new file mode 100644 index 00000000..19fd19ef --- /dev/null +++ b/test/syntax_check/chrono_no_stl.h.t.cpp @@ -0,0 +1,32 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2026 J Wellbelove +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#if !defined(ETL_NO_STL) + #define ETL_NO_STL +#endif + +#include