-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconversions.h
53 lines (40 loc) · 919 Bytes
/
conversions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef _SUMMER_UTIL_CONVERSIONS_H
#define _SUMMER_UTIL_CONVERSIONS_H
#include <string>
namespace summer::util {
template <typename T>
T convert(std::string const& input);
template <>
int convert(std::string const& input) {
return std::stoi(input);
}
template <>
long convert(std::string const& input) {
return std::stol(input);
}
template <>
unsigned long convert(std::string const& input) {
return std::stoul(input);
}
template <>
long long convert(std::string const& input) {
return std::stoll(input);
}
template <>
unsigned long long convert(std::string const& input) {
return std::stoull(input);
}
template <>
float convert(std::string const& input) {
return std::stof(input);
}
template <>
double convert(std::string const& input) {
return std::stod(input);
}
template <>
long double convert(std::string const& input) {
return std::stold(input);
}
}
#endif