From f8e264954eca759ce0589ea25fbb3354f3f31bfe Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Wed, 5 Jan 2022 12:14:48 +0100 Subject: Contiguous range concepts for C++ libs that don't support them yet --- zencore/include/zencore/memory.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'zencore/include') diff --git a/zencore/include/zencore/memory.h b/zencore/include/zencore/memory.h index ef4d3bdbd..40a3be18c 100644 --- a/zencore/include/zencore/memory.h +++ b/zencore/include/zencore/memory.h @@ -14,6 +14,12 @@ namespace zen { +#if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L + template concept ContiguousRange = std::ranges::contiguous_range; +#else + template concept ContiguousRange = true; +#endif + struct MemoryView; class MemoryArena @@ -337,7 +343,7 @@ MakeMemoryView(std::initializer_list::type> List) } /** Make a non-owning view of the memory of the contiguous container. */ -template +template [[nodiscard]] constexpr inline MemoryView MakeMemoryView(const R& Container) { @@ -372,7 +378,7 @@ MakeMutableMemoryView(std::initializer_list::type } /** Make a non-owning mutable view of the memory of the contiguous container. */ -template +template [[nodiscard]] constexpr inline MutableMemoryView MakeMutableMemoryView(R& Container) { -- cgit v1.2.3