Skip to content

Commit

Permalink
Placing definitions in unnamed namespace to prevent multiple definiti…
Browse files Browse the repository at this point in the history
…on linker error #75
  • Loading branch information
p-ranav committed Apr 12, 2020
1 parent 45664c4 commit 4c69ebf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/argparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ struct is_container<
template <typename T>
static constexpr bool is_container_v = is_container<T>::value;

namespace {

template <typename T> constexpr bool standard_signed_integer = false;
template <> constexpr bool standard_signed_integer<signed char> = true;
template <> constexpr bool standard_signed_integer<short int> = true;
Expand All @@ -88,6 +90,8 @@ template <> constexpr bool standard_unsigned_integer<unsigned long int> = true;
template <>
constexpr bool standard_unsigned_integer<unsigned long long int> = true;

}

template <typename T>
constexpr bool standard_integer =
standard_signed_integer<T> || standard_unsigned_integer<T>;
Expand Down Expand Up @@ -186,11 +190,15 @@ template <class T> struct parse_number<T> {
}
};

namespace {

template <class T> constexpr auto generic_strtod = nullptr;
template <> constexpr auto generic_strtod<float> = strtof;
template <> constexpr auto generic_strtod<double> = strtod;
template <> constexpr auto generic_strtod<long double> = strtold;

}

template <class T> inline auto do_strtod(std::string const &s) -> T {
if (isspace(static_cast<unsigned char>(s[0])) || s[0] == '+')
throw std::invalid_argument{"pattern not found"};
Expand Down

0 comments on commit 4c69ebf

Please sign in to comment.