15 #include <type_traits> 29 typename std::aligned_storage<sizeof(T), alignof(T)>::type;
36 template <
typename Iter1,
typename Iter2>
40 std::make_move_iterator(in2),
47 for (; first != last; ++first)
51 template <
class T,
class Size>
59 template <
typename Heap,
typename T,
typename... Args>
62 auto ptr = Heap::allocate(
sizeof(T));
64 return new (ptr) T{std::forward<Args>(args)...};
66 Heap::deallocate(
sizeof(T), ptr);
88 inline constexpr
auto clz_(
unsigned int x) {
return __builtin_clz(x); }
89 inline constexpr
auto clz_(
unsigned long x) {
return __builtin_clzl(x); }
90 inline constexpr
auto clz_(
unsigned long long x) {
return __builtin_clzll(x); }
96 return x <= 1 ? r : log2_aux(x >> 1, r + 1);
100 inline constexpr
auto log2(T x)
101 -> std::enable_if_t<!std::is_same<decltype(clz_(x)), not_supported_t>::value, T>
106 template <
typename T>
107 inline constexpr
auto log2(T x)
108 -> std::enable_if_t<std::is_same<decltype(clz_(x)), not_supported_t>::value, T>
113 template <
bool b,
typename F>
115 { std::forward<F>(f)(
empty_t{}); }
116 template <
bool b,
typename F>
117 auto static_if(F&& f) -> std::enable_if_t<!b>
120 template <
bool b,
typename R=
void,
typename F1,
typename F2>
121 auto static_if(F1&& f1, F2&& f2) -> std::enable_if_t<b, R>
122 {
return std::forward<F1>(f1)(
empty_t{}); }
123 template <
bool b,
typename R=
void,
typename F1,
typename F2>
124 auto static_if(F1&& f1, F2&& f2) -> std::enable_if_t<!b, R>
125 {
return std::forward<F2>(f2)(empty_t{}); }
127 template <
typename T, T value>
130 template <
typename... Args>
137 template <
typename Iterator,
typename Sentinel,
139 <detail::std_distance_supports_v<Iterator,Sentinel>,
bool> =
true>
140 typename std::iterator_traits<Iterator>::difference_type
150 template <
typename Iterator,
typename Sentinel,
152 <(!detail::std_distance_supports_v<Iterator,Sentinel>)
153 && detail::is_forward_iterator_v<Iterator>
154 && detail::compatible_sentinel_v<Iterator,Sentinel>
155 && (!detail::is_subtractable_v<Sentinel, Iterator>),
bool> =
true>
156 typename std::iterator_traits<Iterator>::difference_type
157 distance(Iterator first, Sentinel last)
160 while (first != last) {
171 template <
typename Iterator,
typename Sentinel,
173 <(!detail::std_distance_supports_v<Iterator,Sentinel>)
174 && detail::is_forward_iterator_v<Iterator>
175 && detail::compatible_sentinel_v<Iterator,Sentinel>
176 && detail::is_subtractable_v<Sentinel, Iterator>,
bool> =
true>
177 typename std::iterator_traits<Iterator>::difference_type
178 distance(Iterator first, Sentinel last)
188 template <
typename Iterator,
typename Sentinel,
typename SinkIter,
191 <Iterator,Sentinel,SinkIter>,
bool> =
true>
201 template <
typename SourceIter,
typename Sent,
typename SinkIter,
203 <(!detail::std_uninitialized_copy_supports_v<SourceIter, Sent, SinkIter>)
204 && detail::compatible_sentinel_v<SourceIter,Sent>
205 && detail::is_forward_iterator_v<SinkIter>,
bool> =
true>
208 auto current = d_first;
210 while (first != last) {
215 using Value =
typename std::iterator_traits<SinkIter>::value_type;
216 for (;d_first != current; ++d_first){
void destroy(T *first, T *last)
constexpr auto log2(T x) -> std::enable_if_t<!std::is_same< decltype(clz_(x)), not_supported_t >::value, T >
void destroy_n(T *p, Size n)
std::iterator_traits< Iterator >::difference_type distance(Iterator first, Sentinel last)
SinkIter uninitialized_copy(Iterator first, Sentinel last, SinkIter d_first)
constexpr T log2_aux(T x, T r=0)
constexpr auto clz_(T) -> not_supported_t
auto static_if(F &&f) -> std::enable_if_t< b >
SinkIter uninitialized_copy(SourceIter first, Sent last, SinkIter d_first)
auto uninitialized_move(Iter1 in1, Iter1 in2, Iter2 out)
T & auto_const_cast(const T &x)
#define IMMER_UNREACHABLE
typename std::aligned_storage< sizeof(T), alignof(T)>::type aligned_storage_for
constexpr bool std_uninitialized_copy_supports_v
T operator()(Args &&...) const