mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-31 17:17:50 -05:00
Use std::from_chars to convert to int
This commit is contained in:
1 parent
0f1e09ed9b
commit
3fa59a9fc3
2 files changed
+5
-7
No files matched your search
@@ -21,6 +21,7 @@
|
||||
#include "fast_float/include/fast_float/fast_float.h"
|
||||
|
||||
#include <cctype>
|
||||
#include <charconv>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -122,14 +123,11 @@ bool RiaStdStringTools::toDouble( const std::string_view& s, double& value )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiaStdStringTools::toInt( const std::string& s, int& value )
|
||||
bool RiaStdStringTools::toInt( const std::string_view& s, int& value )
|
||||
{
|
||||
// auto resultObject = std::from_chars( s.data(), s.data() + s.size(), value );
|
||||
// return ( resultObject.ec == std::errc() );
|
||||
auto resultObject = std::from_chars( s.data(), s.data() + s.size(), value );
|
||||
|
||||
value = toInt( s );
|
||||
|
||||
return true;
|
||||
return ( resultObject.ec == std::errc() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user