Placing definitions in unnamed namespace to prevent multiple definition linker error #75

This commit is contained in:
Pranav Srinivas Kumar 2020-04-12 09:38:21 -05:00
parent 45664c4e9f
commit 4c69ebf3fe

View File

@ -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;
@ -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>;
@ -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"};