Merge pull request #329 from rouault/custom_strtoX

Add ways to substitute strtof/strtod/strtold with custom functions
This commit is contained in:
Pranav 2024-03-12 06:59:52 -04:00 committed by GitHub
commit c69d8e1960
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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