std::string_view 的使用
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user