concepts: add the null_stringy concept
This commit is contained in:
parent
b54403557e
commit
85bd599577
@ -13,11 +13,33 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
namespace cruft::concepts {
|
namespace cruft::concepts {
|
||||||
|
/// A literal c-string character array.
|
||||||
|
template <typename T>
|
||||||
|
concept c_string =
|
||||||
|
std::is_array_v<std::remove_cvref_t<T>> and
|
||||||
|
std::is_same_v<
|
||||||
|
std::remove_cvref_t<
|
||||||
|
std::remove_all_extents_t<
|
||||||
|
std::remove_cvref_t<T>
|
||||||
|
>
|
||||||
|
>,
|
||||||
|
char
|
||||||
|
>;
|
||||||
|
|
||||||
/// A type that behaves like a string. ie, a sequence of characters
|
/// A type that behaves like a string. ie, a sequence of characters
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept stringy =
|
concept stringy =
|
||||||
std::same_as<T, std::string> or
|
std::same_as<T, std::string> or
|
||||||
std::same_as<T, std::string_view> or
|
std::same_as<T, std::string_view> or
|
||||||
std::same_as<T, char const*> or
|
std::same_as<T, char const*> or
|
||||||
|
std::same_as<T, char *> or
|
||||||
|
c_string<T>;
|
||||||
|
|
||||||
|
|
||||||
|
/// A type that behaves like a string _and_ has a null terminator
|
||||||
|
template <typename T>
|
||||||
|
concept null_stringy =
|
||||||
|
std::same_as<T, std::string> or
|
||||||
|
std::same_as<T, char const*> or
|
||||||
std::same_as<T, char *>;
|
std::same_as<T, char *>;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user