/**
This file is a part of rexy's general purpose library
Copyright (C) 2022 rexy712
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#ifndef REXY_CONCEPTS_STRING_HPP
#define REXY_CONCEPTS_STRING_HPP
#include //decay
#include //convertible_to
#include //as_const
#include "../traits.hpp"
namespace rexy{
template
class string_cat_expr;
template
class basic_string;
template
class basic_string_view;
template
struct is_basic_string{
template
static std::true_type check(const basic_string*);
static std::false_type check(...);
static constexpr bool value = decltype(check(std::declval*>()))::value;
};
template
struct is_basic_string_view{
template
static std::true_type check(const basic_string_view*);
static std::false_type check(...);
static constexpr bool value = decltype(check(std::declval*>()))::value;
};
template
struct is_basic_string_expr{
template
static std::true_type check(const string_cat_expr*);
static std::false_type check(...);
static constexpr bool value = decltype(check(std::declval*>()))::value;
};
template
concept BasicString = requires(const T& a){
requires(is_basic_string::value || is_basic_string_view::value);
{std::as_const(a).length()} -> std::convertible_to::size_type>;
{std::as_const(a).c_str()} -> std::convertible_to::const_pointer>;
{std::as_const(a)[0]} -> std::convertible_to::const_reference>;
{std::as_const(a).begin()} -> std::convertible_to::const_iterator>;
{std::as_const(a).end()} -> std::convertible_to::const_iterator>;
};
template
concept StringExpr = is_basic_string_expr::value;
template
concept String = BasicString || StringExpr;
template
struct is_string{
static constexpr bool value = BasicString;
};
template
static constexpr bool is_string_v = is_string::value;
template
struct are_strings{
static constexpr bool value = (BasicString && ...);
};
template
static constexpr bool are_strings_v = are_strings::value;
template
struct is_string_expr{
static constexpr bool value = StringExpr;
};
template
static constexpr bool is_string_expr_v = is_string_expr::value;
template
struct are_string_expr{
static constexpr bool value = (StringExpr && ...);
};
template
static constexpr bool are_string_expr_v = are_string_expr::value;
}
#endif