Make allocator and string_base compat easier to read and remove unneccessary concepts subdirectory
This commit is contained in:
@@ -24,11 +24,71 @@
|
||||
#include <utility> //forward
|
||||
#include <type_traits> //decay, is_nothrow_assignable
|
||||
|
||||
#include "../../concepts/string.hpp"
|
||||
#include "../../utility.hpp" //strlen, strncmp
|
||||
|
||||
namespace rexy{
|
||||
|
||||
template<class Left, class Right>
|
||||
class string_cat_expr;
|
||||
template<class Char, REXY_ALLOCATOR_CONCEPT Alloc>
|
||||
class basic_string;
|
||||
template<class Char>
|
||||
class basic_string_view;
|
||||
|
||||
template<class T>
|
||||
struct is_basic_string{
|
||||
template<class Char, class Alloc>
|
||||
static std::true_type check(const basic_string<Char,Alloc>*);
|
||||
static std::false_type check(...);
|
||||
|
||||
static constexpr bool value = decltype(check(std::declval<std::remove_cvref_t<T>*>()))::value;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct is_basic_string_view{
|
||||
template<class Char>
|
||||
static std::true_type check(const basic_string_view<Char>*);
|
||||
static std::false_type check(...);
|
||||
|
||||
static constexpr bool value = decltype(check(std::declval<std::remove_cvref_t<T>*>()))::value;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct is_basic_string_expr{
|
||||
template<class Left, class Right>
|
||||
static std::true_type check(const string_cat_expr<Left,Right>*);
|
||||
static std::false_type check(...);
|
||||
|
||||
static constexpr bool value = decltype(check(std::declval<std::remove_cvref_t<T>*>()))::value;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
concept BasicString = requires(const T& a){
|
||||
requires(is_basic_string<T>::value || is_basic_string_view<T>::value);
|
||||
{std::as_const(a).length()} -> std::convertible_to<typename std::decay_t<T>::size_type>;
|
||||
{std::as_const(a).c_str()} -> std::convertible_to<typename std::decay_t<T>::const_pointer>;
|
||||
{std::as_const(a)[0]} -> std::convertible_to<typename std::decay_t<T>::const_reference>;
|
||||
{std::as_const(a).begin()} -> std::convertible_to<typename std::decay_t<T>::const_iterator>;
|
||||
{std::as_const(a).end()} -> std::convertible_to<typename std::decay_t<T>::const_iterator>;
|
||||
};
|
||||
template<class T>
|
||||
concept StringExpr = is_basic_string_expr<T>::value;
|
||||
template<class T>
|
||||
concept String = BasicString<T> || StringExpr<T>;
|
||||
|
||||
template<class T>
|
||||
struct is_string{
|
||||
static constexpr bool value = BasicString<T>;
|
||||
};
|
||||
template<class T>
|
||||
static constexpr bool is_string_v = is_string<T>::value;
|
||||
template<class T>
|
||||
struct is_string_expr{
|
||||
static constexpr bool value = StringExpr<T>;
|
||||
};
|
||||
template<class T>
|
||||
static constexpr bool is_string_expr_v = is_string_expr<T>::value;
|
||||
|
||||
//Compare
|
||||
template<BasicString Str1, BasicString Str2>
|
||||
constexpr bool operator==(Str1&& left, Str2&& right){
|
||||
|
||||
Reference in New Issue
Block a user