std::string_view 的使用

This commit is contained in:
2026-06-29 09:40:55 +08:00
parent ccf7eecc29
commit c25e58ae17
40 changed files with 532 additions and 522 deletions
+3 -2
View File
@@ -1,6 +1,7 @@
#include "TCP_Server.h"
#include <array>
#include <string_view>
namespace Psc::asio_socket {
@@ -48,7 +49,7 @@ TCP_Server &TCP_Server::create() {
return *this;
}
bool TCP_Server::listen(const std::string &ip, std::uint32_t port) {
bool TCP_Server::listen(std::string_view ip, std::uint32_t port) {
return listen(Sockaddr_In(ip, port));
}
@@ -265,7 +266,7 @@ void TCP_Server::flush_clients() {
}
}
void TCP_Server::write_to_all_clients(const std::string &data) {
void TCP_Server::write_to_all_clients(std::string_view data) {
if (data.empty())
return;
for (auto &[_, conn] : tcp_clients) {