From 5de588434175457016c426631b444e1eb5fba982 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 1 Oct 2019 14:31:00 +0200 Subject: [PATCH] pass by reference --- slsSupportLib/include/ToString.h | 9 +++++---- slsSupportLib/tests/test-ToString.cpp | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/slsSupportLib/include/ToString.h b/slsSupportLib/include/ToString.h index 187ab91d4..52b25a655 100644 --- a/slsSupportLib/include/ToString.h +++ b/slsSupportLib/include/ToString.h @@ -159,13 +159,14 @@ T StringTo(const std::string &t, const std::string &unit) { } } -template T StringTo(std::string t) { - auto unit = RemoveUnit(t); - return StringTo(t, unit); +template T StringTo(const std::string& t) { + std::string tmp{t}; + auto unit = RemoveUnit(tmp); + return StringTo(tmp, unit); } template <> -inline slsDetectorDefs::detectorType StringTo(std::string s){ +inline slsDetectorDefs::detectorType StringTo(const std::string& s){ return slsDetectorDefs::detectorTypeToEnum(s); } diff --git a/slsSupportLib/tests/test-ToString.cpp b/slsSupportLib/tests/test-ToString.cpp index a7dfc5a17..62d59462d 100644 --- a/slsSupportLib/tests/test-ToString.cpp +++ b/slsSupportLib/tests/test-ToString.cpp @@ -120,7 +120,6 @@ TEST_CASE("string to std::chrono::duration", "[support]") { REQUIRE(StringTo("150ns") == ns(150)); REQUIRE(StringTo("150s") == s(150)); REQUIRE(StringTo("3 s") == s(3)); - REQUIRE_THROWS(StringTo("5xs")); REQUIRE_THROWS(StringTo("asvn")); }