Files
Adminive/backend/include/adminive/concepts.hpp
T
2026-08-06 16:01:04 +08:00

38 lines
1.3 KiB
C++

#pragma once
#include "adminive/value.hpp"
#include <concepts>
#include <map>
#include <string>
#include <string_view>
#include <type_traits>
#include <vector>
namespace adminive {
template <class T>
concept String_Type = std::same_as<std::remove_cvref_t<T>, std::string> || std::same_as<std::remove_cvref_t<T>, std::string_view>;
template <class T>
concept Sequence_Type = requires(T value) {
typename std::remove_cvref_t<T>::value_type;
value.begin();
value.end();
value.size();
} && !String_Type<T>;
template <class T>
concept String_Key_Map_Type = requires(T value) {
typename std::remove_cvref_t<T>::key_type;
typename std::remove_cvref_t<T>::mapped_type;
requires String_Type<typename std::remove_cvref_t<T>::key_type>;
value.begin();
value.end();
};
template <class T>
concept Json_Scalar_Type = std::same_as<Unwrapped_Value_Type<T>, bool> || std::integral<Unwrapped_Value_Type<T>> || std::floating_point<Unwrapped_Value_Type<T>> || String_Type<Unwrapped_Value_Type<T>> || std::is_enum_v<Unwrapped_Value_Type<T>>;
template <class Validator>
concept Multiple_Of_Validator = requires {
{ Validator::multiple_of };
};
template <class Validator>
concept Validator_With_Message = requires {
{ Validator::message } -> std::convertible_to<std::string_view>;
};
}