|
6 | 6 | #ifndef LIB_JXL_BASE_COMMON_H_ |
7 | 7 | #define LIB_JXL_BASE_COMMON_H_ |
8 | 8 |
|
9 | | -// Shared constants and helper functions. |
10 | | - |
11 | | -#include <cstddef> |
12 | | -#include <cstdint> |
13 | | -#include <cstdio> |
14 | 9 | #include <memory> |
15 | | -#include <string> |
16 | 10 |
|
17 | 11 | namespace coder { |
18 | 12 | // Some enums and typedefs used by more than one header file. |
@@ -56,38 +50,11 @@ namespace coder { |
56 | 50 | return static_cast<T>(multiplier * kPi); |
57 | 51 | } |
58 | 52 |
|
59 | | -// Prior to C++14 (i.e. C++11): provide our own make_unique |
60 | | -#if __cplusplus < 201402L |
61 | | - template <typename T, typename... Args> |
62 | | - std::unique_ptr<T> make_unique(Args&&... args) { |
63 | | - return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); |
64 | | - } |
65 | | -#else |
66 | | - using std::make_unique; |
67 | | -#endif |
68 | | - |
69 | 53 | template<typename T> |
70 | 54 | inline T Clamp1(T val, T low, T hi) { |
71 | 55 | return val < low ? low : val > hi ? hi : val; |
72 | 56 | } |
73 | 57 |
|
74 | | -// conversion from integer to string. |
75 | | - template<typename T> |
76 | | - std::string ToString(T n) { |
77 | | - char data[32] = {}; |
78 | | - if (T(0.1) != T(0)) { |
79 | | - // float |
80 | | - snprintf(data, sizeof(data), "%g", static_cast<double>(n)); |
81 | | - } else if (T(-1) > T(0)) { |
82 | | - // unsigned |
83 | | - snprintf(data, sizeof(data), "%llu", static_cast<unsigned long long>(n)); |
84 | | - } else { |
85 | | - // signed |
86 | | - snprintf(data, sizeof(data), "%lld", static_cast<long long>(n)); |
87 | | - } |
88 | | - return data; |
89 | | - } |
90 | | - |
91 | 58 | } // namespace jxl |
92 | 59 |
|
93 | 60 | #endif // LIB_JXL_BASE_COMMON_H_ |
0 commit comments