From cf51c6f2b2a7a29b9156e5ccd887ebf086af1dd2 Mon Sep 17 00:00:00 2001 From: David Tran Date: Fri, 30 Dec 2022 12:27:56 -0500 Subject: [PATCH 1/2] Implement std::size and std::ssize for C-style arrays --- include/frg/array.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/frg/array.hpp b/include/frg/array.hpp index 0184edf..ab9bc62 100644 --- a/include/frg/array.hpp +++ b/include/frg/array.hpp @@ -128,6 +128,18 @@ constexpr auto array_concat(const Ts &...arrays) { namespace std { +template +constexpr size_t size(const T (&array)[N]) noexcept +{ + return N; +} + +template +constexpr ptrdiff_t ssize(const T (&array)[N]) noexcept +{ + return N; +} + template constexpr T &get(frg::array &a) noexcept { static_assert(I < N, "array index is not within bounds"); From ed74b7ebeefa7f3749884437a4bca4243e4525e1 Mon Sep 17 00:00:00 2001 From: David Tran Date: Fri, 30 Dec 2022 15:17:06 -0500 Subject: [PATCH 2/2] Fix styling --- include/frg/array.hpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/frg/array.hpp b/include/frg/array.hpp index ab9bc62..5f9158e 100644 --- a/include/frg/array.hpp +++ b/include/frg/array.hpp @@ -129,15 +129,13 @@ constexpr auto array_concat(const Ts &...arrays) { namespace std { template -constexpr size_t size(const T (&array)[N]) noexcept -{ - return N; +constexpr size_t size(const T (&array)[N]) noexcept { + return N; } template -constexpr ptrdiff_t ssize(const T (&array)[N]) noexcept -{ - return N; +constexpr ptrdiff_t ssize(const T (&array)[N]) noexcept { + return N; } template