From c944e36e8a0263df3e1805a8db735f91236c7f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Can=20B=C3=B6l=C3=BCk?= Date: Mon, 28 Sep 2020 02:12:04 +0200 Subject: [PATCH 1/4] Use std::size instead of sizeof, breaks on MS STL + clang10. --- src/c4/charconv.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c4/charconv.hpp b/src/c4/charconv.hpp index b5b65ea0..7e4bf2ea 100644 --- a/src/c4/charconv.hpp +++ b/src/c4/charconv.hpp @@ -126,7 +126,7 @@ inline C4_CONSTEXPR14 char to_c_fmt(RealFormat_e f) 'g', // FTOA_FLEX 'a', // FTOA_HEXA }; - C4_STATIC_ASSERT(sizeof(fmt) == _FTOA_COUNT); + C4_STATIC_ASSERT( std::size(fmt) == _FTOA_COUNT); C4_ASSERT(f < _FTOA_COUNT); return fmt[f]; } @@ -141,7 +141,7 @@ inline constexpr std::chars_format to_std_fmt(RealFormat_e f) std::chars_format::general, // FTOA_FLEX std::chars_format::hex, // FTOA_HEXA }; - C4_STATIC_ASSERT(sizeof(fmt) == _FTOA_COUNT); + C4_STATIC_ASSERT(std::size(fmt) == _FTOA_COUNT); C4_ASSERT(f < _FTOA_COUNT); return fmt[f]; } From 6e84cbe8648ab1c18d2a302d13686ecfcc830205 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Can=20B=C3=B6l=C3=BCk?= Date: Mon, 28 Sep 2020 02:15:51 +0200 Subject: [PATCH 2/4] No algo so fix again. --- src/c4/charconv.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/c4/charconv.hpp b/src/c4/charconv.hpp index 7e4bf2ea..0127f2de 100644 --- a/src/c4/charconv.hpp +++ b/src/c4/charconv.hpp @@ -126,7 +126,7 @@ inline C4_CONSTEXPR14 char to_c_fmt(RealFormat_e f) 'g', // FTOA_FLEX 'a', // FTOA_HEXA }; - C4_STATIC_ASSERT( std::size(fmt) == _FTOA_COUNT); + C4_STATIC_ASSERT(sizeof(fmt) == _FTOA_COUNT); C4_ASSERT(f < _FTOA_COUNT); return fmt[f]; } @@ -141,7 +141,7 @@ inline constexpr std::chars_format to_std_fmt(RealFormat_e f) std::chars_format::general, // FTOA_FLEX std::chars_format::hex, // FTOA_HEXA }; - C4_STATIC_ASSERT(std::size(fmt) == _FTOA_COUNT); + C4_STATIC_ASSERT((sizeof(fmt)/sizeof(std::chars_format)) == _FTOA_COUNT); C4_ASSERT(f < _FTOA_COUNT); return fmt[f]; } From 8f304e479b64986ef847c1b1befbfca456b884b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Can=20B=C3=B6l=C3=BCk?= Date: Mon, 28 Sep 2020 02:26:15 +0200 Subject: [PATCH 3/4] Just include iterator. --- src/c4/charconv.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/c4/charconv.hpp b/src/c4/charconv.hpp index 0127f2de..4fd43f94 100644 --- a/src/c4/charconv.hpp +++ b/src/c4/charconv.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #if (C4_CPP >= 17) # if defined(_MSC_VER) @@ -126,7 +127,7 @@ inline C4_CONSTEXPR14 char to_c_fmt(RealFormat_e f) 'g', // FTOA_FLEX 'a', // FTOA_HEXA }; - C4_STATIC_ASSERT(sizeof(fmt) == _FTOA_COUNT); + C4_STATIC_ASSERT(std::size(fmt) == _FTOA_COUNT); C4_ASSERT(f < _FTOA_COUNT); return fmt[f]; } @@ -141,7 +142,7 @@ inline constexpr std::chars_format to_std_fmt(RealFormat_e f) std::chars_format::general, // FTOA_FLEX std::chars_format::hex, // FTOA_HEXA }; - C4_STATIC_ASSERT((sizeof(fmt)/sizeof(std::chars_format)) == _FTOA_COUNT); + C4_STATIC_ASSERT(std::size(fmt) == _FTOA_COUNT); C4_ASSERT(f < _FTOA_COUNT); return fmt[f]; } From 28466ae10c1ed28e4f77acefe9800c4a5fe5a21a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Can=20B=C3=B6l=C3=BCk?= Date: Tue, 29 Sep 2020 22:31:15 +0200 Subject: [PATCH 4/4] Replace std::size with C4_COUNTOF. --- src/c4/charconv.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/c4/charconv.hpp b/src/c4/charconv.hpp index 4fd43f94..73b6d3fd 100644 --- a/src/c4/charconv.hpp +++ b/src/c4/charconv.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #if (C4_CPP >= 17) # if defined(_MSC_VER) @@ -127,7 +126,7 @@ inline C4_CONSTEXPR14 char to_c_fmt(RealFormat_e f) 'g', // FTOA_FLEX 'a', // FTOA_HEXA }; - C4_STATIC_ASSERT(std::size(fmt) == _FTOA_COUNT); + C4_STATIC_ASSERT(C4_COUNTOF(fmt) == _FTOA_COUNT); C4_ASSERT(f < _FTOA_COUNT); return fmt[f]; } @@ -142,7 +141,7 @@ inline constexpr std::chars_format to_std_fmt(RealFormat_e f) std::chars_format::general, // FTOA_FLEX std::chars_format::hex, // FTOA_HEXA }; - C4_STATIC_ASSERT(std::size(fmt) == _FTOA_COUNT); + C4_STATIC_ASSERT(C4_COUNTOF(fmt) == _FTOA_COUNT); C4_ASSERT(f < _FTOA_COUNT); return fmt[f]; }