mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 17:57:01 +08:00
style. use same_as && derived_from
This commit is contained in:
@@ -41,7 +41,7 @@ namespace asst
|
||||
|
||||
template<typename PluginType>
|
||||
std::shared_ptr<PluginType> register_plugin()
|
||||
requires std::is_base_of_v<AbstractTaskPlugin, PluginType> // Plugin must inherit AbstractTaskPlugin
|
||||
requires std::derived_from<PluginType, AbstractTaskPlugin> // Plugin must inherit AbstractTaskPlugin
|
||||
{
|
||||
auto plugin = std::make_shared<PluginType>(m_callback, m_callback_arg, m_task_chain);
|
||||
m_plugins.emplace(plugin);
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace asst::utils
|
||||
|
||||
template<typename map_t>
|
||||
inline std::string string_replace_all_batch(const std::string& src, const map_t& replace_pairs)
|
||||
requires std::is_base_of_v<typename map_t::value_type::first_type, std::string>
|
||||
&& std::is_base_of_v<typename map_t::value_type::second_type, std::string>
|
||||
requires std::derived_from<map_t::value_type::first_type, std::string>
|
||||
&& std::derived_from<map_t::value_type::second_type, std::string>
|
||||
{
|
||||
std::string str = src;
|
||||
for (const auto& [old_value, new_value] : replace_pairs) {
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace asst
|
||||
const std::unordered_set<std::string>& get_templ_required() const noexcept;
|
||||
|
||||
template<typename TargetTaskInfoType>
|
||||
requires std::is_base_of_v<TaskInfo, TargetTaskInfoType>
|
||||
&& !std::is_same_v<TaskInfo, TargetTaskInfoType> // Parameter must be a TaskInfo
|
||||
requires std::derived_from<TargetTaskInfoType, TaskInfo>
|
||||
&& !std::same_as<TargetTaskInfoType, TaskInfo> // Parameter must be a TaskInfo and not same as TaskInfo
|
||||
std::shared_ptr<TargetTaskInfoType> get(const std::string& name)
|
||||
{
|
||||
auto it = m_all_tasks_info.find(name);
|
||||
@@ -39,7 +39,7 @@ namespace asst
|
||||
}
|
||||
|
||||
template<typename TargetTaskInfoType = TaskInfo>
|
||||
requires std::is_same_v<TaskInfo, TargetTaskInfoType> // Parameter must be a TaskInfo
|
||||
requires std::same_as<TargetTaskInfoType, TaskInfo> // Parameter must be a TaskInfo
|
||||
std::shared_ptr<TargetTaskInfoType> get(const std::string& name)
|
||||
{
|
||||
auto it = m_all_tasks_info.find(name);
|
||||
|
||||
Reference in New Issue
Block a user