Browse Source

* Use convert_cast instead of static_cast where feasible

master
bergmann 4 years ago
parent
commit
5beb419388
3 changed files with 7 additions and 3 deletions
  1. +3
    -1
      include/cppargs/misc/context.inl
  2. +3
    -1
      include/cppargs/misc/option_parser.inl
  3. +1
    -1
      test/CMakeLists.txt

+ 3
- 1
include/cppargs/misc/context.inl View File

@@ -1,5 +1,7 @@
#pragma once

#include <cppcore/conversion/convert_cast.h>

#include "context.h"

namespace cppargs
@@ -39,7 +41,7 @@ namespace cppargs
{
value = tmp + 1;
if (key)
*key = std::string(arg, static_cast<size_t>(tmp - arg));
*key = std::string(arg, cppcore::convert_cast<size_t>(tmp - arg));
}
else if (key)
{


+ 3
- 1
include/cppargs/misc/option_parser.inl View File

@@ -2,7 +2,9 @@

#include <list>
#include <vector>

#include <cppcore/conversion/string.h>
#include <cppcore/conversion/convert_cast.h>
#include <cppargs/misc/option_parser.h>

namespace cppargs
@@ -138,7 +140,7 @@ namespace cppargs
|| *e == '\0'))
{
value_type tmp;
std::string str(s, static_cast<size_t>(e - s));
std::string str(s, cppcore::convert_cast<size_t>(e - s));
s = e + 1;
if (!cppcore::try_from_string(str, tmp))
throw std::runtime_error(std::string("unable to parse option argument (option=") + arg + "; value=" + s + ")");


+ 1
- 1
test/CMakeLists.txt View File

@@ -45,7 +45,7 @@ ForEach ( FILE IN LISTS CPPARGS_TEST_SOURCE_FILES )

# test
If ( HAS_CMAKE_TESTS )
Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} )
Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} GROUP cppargs )
Else ( )
Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
EndIf ( )


Loading…
Cancel
Save