29 lines
1.1 KiB
C++
29 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include "error.hpp"
|
|
|
|
using param_str = const std::string_view&;
|
|
using ret_str = std::pmr::string;
|
|
|
|
|
|
inline bool operator==(const std::string& lhs, const std::pmr::string& rhs) {
|
|
std::string_view sv_lhs(lhs); // 将 std::string 转换为 string_view
|
|
std::string_view sv_rhs(rhs.data(), rhs.size()); // 将 pmr::string 转换为 string_view
|
|
return sv_lhs == sv_rhs; // 使用 string_view 进行比较
|
|
}
|
|
|
|
inline std::string operator+(const std::string& lhs, const std::pmr::string& rhs) {
|
|
std::string result(lhs); // 创建一个新的 std::string 以容纳拼接结果
|
|
result.append(rhs.data(), rhs.size()); // 将 pmr::string 的数据追加到 std::string
|
|
return result;
|
|
}
|
|
|
|
// 反过来,比较 pmr::string 和 std::string 的拼接
|
|
inline std::pmr::string operator+(const std::pmr::string& lhs, const std::string& rhs) {
|
|
std::pmr::string result(lhs.data(), lhs.size()); // 创建一个新的 pmr::string 以容纳拼接结果
|
|
result.append(rhs); // 将 std::string 的数据追加到 pmr::string
|
|
return result;
|
|
}
|
|
|