16 #ifndef FOXXLL_COMMON_UTILS_HEADER 17 #define FOXXLL_COMMON_UTILS_HEADER 25 #include <type_traits> 30 #include <foxxll/config.hpp> 35 template <
typename Type>
38 std::ostringstream oss;
55 return _strtoui64(s,
nullptr, 10);
57 return strtoull(s,
nullptr, 10);
61 template <
typename Integral,
typename Integral2>
63 typename std::remove_const<Integral>::type
66 #if 0 // ambiguous overload for std::div(unsigned_anything, unsigned_anything) 67 using div_type = __typeof__(std::div(n, d));
68 div_type result = std::div(n, d);
69 return result.quot + (result.rem != 0);
71 return n / d + ((n % d) != 0);
77 key_ += ~(key_ << 32);
79 key_ += ~(key_ << 13);
83 key_ += ~(key_ << 27);
85 return static_cast<size_t>(key_);
91 for (
size_t i = 0; i < size; ++i)
96 template <
typename Integral>
99 auto pot = Integral(1) << power;
103 return (n & ~mask) + pot;
108 template <
class Container>
109 inline typename Container::value_type
pop(Container& c)
111 const auto r = c.top();
116 template <
class Container>
117 inline typename Container::value_type
pop_front(Container& c)
119 const auto r = c.front();
124 template <
class Container>
125 inline typename Container::value_type
pop_back(Container& c)
127 const auto r = c.back();
132 template <
class Container>
133 inline typename Container::value_type
pop_begin(Container& c)
135 const auto r = *c.begin();
142 #endif // !FOXXLL_COMMON_UTILS_HEADER void swap_1D_arrays(Type *a, Type *b, size_t size)
size_t longhash1(uint64_t key_)
Container::value_type pop_begin(Container &c)
std::string to_str(const Type &t)
Format any ostream-able type into a string.
Container::value_type pop_back(Container &c)
void swap(CountingPtr< A, D > &a1, CountingPtr< A, D > &a2) noexcept
Container::value_type pop(Container &c)
std::remove_const< Integral >::type div_ceil(Integral n, Integral2 d)
uint64_t atouint64(const char *s)
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Container::value_type pop_front(Container &c)
Integral round_up_to_power_of_two(Integral n, unsigned power)
round n up to next larger multiple of 2^power. example: (48,4) = 64, (48,3) = 48. ...
int64_t atoi64(const char *s)