From 85bd599577d6800259dfa8c2734c414462e71877 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 20 Jun 2022 09:30:45 +1000 Subject: [PATCH] concepts: add the null_stringy concept --- concepts/string.hpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/concepts/string.hpp b/concepts/string.hpp index a7c2da35..f028408d 100644 --- a/concepts/string.hpp +++ b/concepts/string.hpp @@ -13,11 +13,33 @@ #include namespace cruft::concepts { + /// A literal c-string character array. + template + concept c_string = + std::is_array_v> and + std::is_same_v< + std::remove_cvref_t< + std::remove_all_extents_t< + std::remove_cvref_t + > + >, + char + >; + /// A type that behaves like a string. ie, a sequence of characters template concept stringy = std::same_as or std::same_as or std::same_as or - std::same_as; + std::same_as or + c_string; + + + /// A type that behaves like a string _and_ has a null terminator + template + concept null_stringy = + std::same_as or + std::same_as or + std::same_as; }