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