mirror of
https://github.com/KeqingMoe/argparse.git
synced 2025-07-04 07:04:39 +00:00
Merge pull request #329 from rouault/custom_strtoX
Add ways to substitute strtof/strtod/strtold with custom functions
This commit is contained in:
commit
c69d8e1960
@ -58,6 +58,18 @@ SOFTWARE.
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ARGPARSE_CUSTOM_STRTOF
|
||||||
|
#define ARGPARSE_CUSTOM_STRTOF strtof
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ARGPARSE_CUSTOM_STRTOD
|
||||||
|
#define ARGPARSE_CUSTOM_STRTOD strtod
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ARGPARSE_CUSTOM_STRTOLD
|
||||||
|
#define ARGPARSE_CUSTOM_STRTOLD strtold
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace argparse {
|
namespace argparse {
|
||||||
|
|
||||||
namespace details { // namespace for helper methods
|
namespace details { // namespace for helper methods
|
||||||
@ -347,9 +359,10 @@ template <class T> struct parse_number<T> {
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
template <class T> inline const auto generic_strtod = nullptr;
|
template <class T> inline const auto generic_strtod = nullptr;
|
||||||
template <> inline const auto generic_strtod<float> = strtof;
|
template <> inline const auto generic_strtod<float> = ARGPARSE_CUSTOM_STRTOF;
|
||||||
template <> inline const auto generic_strtod<double> = strtod;
|
template <> inline const auto generic_strtod<double> = ARGPARSE_CUSTOM_STRTOD;
|
||||||
template <> inline const auto generic_strtod<long double> = strtold;
|
template <>
|
||||||
|
inline const auto generic_strtod<long double> = ARGPARSE_CUSTOM_STRTOLD;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user