24 #ifndef __TPIE_UTIL_H__
25 #define __TPIE_UTIL_H__
26 #include <tpie/tpie_export.h>
27 #include <tpie/config.h>
42 inline void unused(
const T & x) {(void)x;}
44 template <
typename T>
struct sign {
typedef T type;};
45 template <>
struct sign<uint8_t> {
typedef int8_t type;};
46 template <>
struct sign<uint16_t> {
typedef int16_t type;};
47 template <>
struct sign<uint32_t> {
typedef int32_t type;};
48 template <>
struct sign<uint64_t> {
typedef int64_t type;};
50 template <
typename T>
struct unsign {
typedef T type;};
51 template <>
struct unsign<int8_t> {
typedef uint8_t type;};
52 template <>
struct unsign<int16_t> {
typedef uint16_t type;};
53 template <>
struct unsign<int32_t> {
typedef uint32_t type;};
54 template <>
struct unsign<int64_t> {
typedef uint64_t type;};
57 const char directory_delimiter =
'\\';
59 const char directory_delimiter =
'/';
63 const double coefficient;
64 const double overhead;
66 coefficient(coefficient), overhead(overhead) {}
68 constexpr memory_size_type operator()(memory_size_type size)
const noexcept {
69 return static_cast<memory_size_type
>(
70 static_cast<double>(size) * coefficient + overhead);
97 template <
typename child_t>
106 static constexpr memory_size_type
memory_usage(memory_size_type size) noexcept {
107 return static_cast<memory_size_type
>(
108 floor(
static_cast<double>(size) * child_t::memory_coefficient() + child_t::memory_overhead()));
118 static constexpr memory_size_type
memory_fits(memory_size_type memory) noexcept {
119 return static_cast<memory_size_type
>(
120 floor((memory - child_t::memory_overhead()) / child_t::memory_coefficient()));
140 static const size_t v=1;
148 template <
typename T,
typename C>
155 if (c < n && lt(*(a+i), *(a+c)))
156 std::swap(*(a+c), *(a+i));
159 if (lt(*(a+c+1), *(a+c))) {
160 if (lt(*(a+i), *(a+c))) {
161 std::swap(*(a+c), *(a+i));
165 if (lt(*(a+i), *(a+c+1))) {
166 std::swap(*(a+c+1), *(a+i));
177 template <
typename T>
186 template <
typename T>
190 template<
typename T1,
typename T2>
191 bool operator()(
const T1 & x,
const T2 & y)
const {
194 template<
typename T1,
typename T2>
195 bool operator()(
const T1 & x,
const T2 & y) {
203 TPIE_EXPORT
void atomic_rename(
const std::string & src,
const std::string & dst);
216 template <
typename T>
223 TPIE_EXPORT
void throw_getlasterror();
228 #endif //__TPIE_UTIL_H__