From 061ec3bcadedcace6921a7af81927f0d1a6749ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Ma=C5=82ecki?= Date: Mon, 22 Jul 2024 13:28:48 +0200 Subject: [PATCH] Added UDL for fmt_stringview to simplify raw string format passing --- apps/transmitmedia.cpp | 2 +- srtcore/ofmt.h | 5 +++++ testing/testmedia.cpp | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/transmitmedia.cpp b/apps/transmitmedia.cpp index 322ac6405..8ec4751dd 100644 --- a/apps/transmitmedia.cpp +++ b/apps/transmitmedia.cpp @@ -524,7 +524,7 @@ SrtCommon::~SrtCommon() SrtSource::SrtSource(string host, int port, const map& par) { Init(host, port, par, false); - hostport_copy = srt::ocat(host, OFMT_RAWSTR(":"), port); + hostport_copy = srt::ocat(host, ":"_V, port); } int SrtSource::Read(size_t chunk, MediaPacket& pkt, ostream &out_stats) diff --git a/srtcore/ofmt.h b/srtcore/ofmt.h index 1c901327a..e2af8b46b 100644 --- a/srtcore/ofmt.h +++ b/srtcore/ofmt.h @@ -318,6 +318,11 @@ class ofmtstream #if (defined(__cplusplus) && __cplusplus > 199711L) \ || (defined(_MSVC_LANG) && _MSVC_LANG > 199711L) // Some earlier versions get this wrong +inline internal::fmt_stringview operator""_V(const char* ptr, size_t s) +{ + return internal::fmt_stringview(ptr, s); +} + template inline Stream& oprint(Stream& out) { diff --git a/testing/testmedia.cpp b/testing/testmedia.cpp index 5387d73e1..d50e5fa5c 100755 --- a/testing/testmedia.cpp +++ b/testing/testmedia.cpp @@ -1606,7 +1606,7 @@ void SrtCommon::UpdateGroupStatus(const SRT_SOCKGROUPDATA* grpdata, size_t grpda SrtSource::SrtSource(string host, int port, std::string path, const map& par) { Init(host, port, path, par, SRT_EPOLL_IN); - hostport_copy = srt::ocat(host, OFMT_RAWSTR(":"), port); + hostport_copy = srt::ocat(host, ":"_V, port); } static void PrintSrtStats(SRTSOCKET sock, bool clr, bool bw, bool stats)