Skip to content

Commit

Permalink
don't use to_string method for converting string_view to string
Browse files Browse the repository at this point in the history
  • Loading branch information
phlptp committed Jun 6, 2020
1 parent 8bbab6f commit 0912199
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gmlc/utilities/string_viewConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ namespace utilities {
template<>
inline long double numConv(string_view V)
{
return std::stold(V.to_string());
return std::stold(std::string(V.data(),V.length()));
}

// template for numeric conversion returning the position
Expand All @@ -154,19 +154,19 @@ namespace utilities {
template<>
inline float numConvComp(string_view V, size_t& rem)
{
return std::stof(V.to_string(), &rem);
return std::stof(std::string(V.data(), V.length()), &rem);
}

template<>
inline double numConvComp(string_view V, size_t& rem)
{
return std::stod(V.to_string(), &rem);
return std::stod(std::string(V.data(), V.length()), &rem);
}

template<>
inline long double numConvComp(string_view V, size_t& rem)
{
return std::stold(V.to_string(), &rem);
return std::stold(std::string(V.data(), V.length()), &rem);
}

/** check if the first character of the string is a valid numerical value*/
Expand Down

0 comments on commit 0912199

Please sign in to comment.