std::string_view 的使用

This commit is contained in:
2026-06-29 09:40:55 +08:00
parent cd446b7ca8
commit 8daf67aa5d
52 changed files with 1420 additions and 1367 deletions
+5 -4
View File
@@ -21,6 +21,7 @@
#include "Core/Base/SM_RingBuffer.h"
#include "Dll_Global.h"
#include <string_view>
std::vector<std::string> ddd = {
@@ -53,7 +54,7 @@ std::string get_absb() {
class TextLineReader {
public:
explicit TextLineReader(const std::string& file_path) {
explicit TextLineReader(std::string_view file_path) {
load(file_path);
}
@@ -86,10 +87,10 @@ public:
}
private:
void load(const std::string& file_path) {
std::ifstream file(file_path);
void load(std::string_view file_path) {
std::ifstream file{std::string(file_path)};
if (!file.is_open()) {
throw std::runtime_error("Failed to open file: " + file_path);
throw std::runtime_error("Failed to open file: " + std::string(file_path));
}
std::string line;