#include <locale>
#include <stdexcept>
#include <string>
+#include <type_traits>
#include <vector>
#include "base/logging.hh"
* integeral type, as well as enums and floating-point types.
*/
template <class T>
-typename std::enable_if<(std::is_integral<T>::value ||
- std::is_enum<T>::value) &&
+typename std::enable_if<std::is_integral<T>::value &&
std::is_signed<T>::value, T>::type
__to_number(const std::string &value)
{
}
template <class T>
-typename std::enable_if<(std::is_integral<T>::value ||
- std::is_enum<T>::value) &&
+typename std::enable_if<std::is_integral<T>::value &&
!std::is_signed<T>::value, T>::type
__to_number(const std::string &value)
{
return static_cast<T>(r);
}
+template <class T>
+typename std::enable_if<std::is_enum<T>::value, T>::type
+__to_number(const std::string &value)
+{
+ auto r = __to_number<typename std::underlying_type<T>::type>(value);
+ return static_cast<T>(r);
+}
+
template <class T>
typename std::enable_if<std::is_floating_point<T>::value, T>::type
__to_number(const std::string &value)