pass by reference

This commit is contained in:
Erik Frojdh 2019-10-01 14:31:00 +02:00
parent b4f3c0586f
commit 5de5884341
2 changed files with 5 additions and 5 deletions

View File

@ -159,13 +159,14 @@ T StringTo(const std::string &t, const std::string &unit) {
}
}
template <typename T> T StringTo(std::string t) {
auto unit = RemoveUnit(t);
return StringTo<T>(t, unit);
template <typename T> T StringTo(const std::string& t) {
std::string tmp{t};
auto unit = RemoveUnit(tmp);
return StringTo<T>(tmp, unit);
}
template <>
inline slsDetectorDefs::detectorType StringTo(std::string s){
inline slsDetectorDefs::detectorType StringTo(const std::string& s){
return slsDetectorDefs::detectorTypeToEnum(s);
}

View File

@ -120,7 +120,6 @@ TEST_CASE("string to std::chrono::duration", "[support]") {
REQUIRE(StringTo<ns>("150ns") == ns(150));
REQUIRE(StringTo<ns>("150s") == s(150));
REQUIRE(StringTo<s>("3 s") == s(3));
REQUIRE_THROWS(StringTo<ns>("5xs"));
REQUIRE_THROWS(StringTo<ns>("asvn"));
}