forked from OctaForge/libostd
type/include cleanup
This commit is contained in:
parent
a913f7beca
commit
1525edf3d7
|
@ -6,8 +6,7 @@
|
|||
#ifndef OSTD_ALGORITHM_HH
|
||||
#define OSTD_ALGORITHM_HH
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
@ -148,10 +147,9 @@ namespace detail {
|
|||
|
||||
template<typename R, typename C>
|
||||
inline void introsort(R range, C &compare) {
|
||||
detail::introloop(
|
||||
range, compare,
|
||||
static_cast<range_size_t<R>>(2 * (log(range.size()) / log(2)))
|
||||
);
|
||||
detail::introloop(range, compare, static_cast<range_size_t<R>>(
|
||||
2 * (std::log(range.size()) / std::log(2))
|
||||
));
|
||||
}
|
||||
} /* namespace detail */
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#ifndef OSTD_CONCURRENCY_HH
|
||||
#define OSTD_CONCURRENCY_HH
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <thread>
|
||||
|
@ -162,7 +163,7 @@ public:
|
|||
|
||||
/** @brief Deallocates a stack allocated with allocate_stack().
|
||||
*
|
||||
* @see allocate_stack(), reserve_stacks(size_t), get_stack_allocator()
|
||||
* @see allocate_stack(), reserve_stacks(), get_stack_allocator()
|
||||
*/
|
||||
virtual void deallocate_stack(stack_context &st) noexcept = 0;
|
||||
|
||||
|
@ -174,7 +175,7 @@ public:
|
|||
*
|
||||
* @see allocate_stack(), deallocate_stack(), get_stack_allocator()
|
||||
*/
|
||||
virtual void reserve_stacks(size_t n) = 0;
|
||||
virtual void reserve_stacks(std::size_t n) = 0;
|
||||
|
||||
/** @brief Gets a stack allocator using the scheduler's stack allocation.
|
||||
*
|
||||
|
@ -355,7 +356,7 @@ struct basic_thread_scheduler: scheduler {
|
|||
}
|
||||
}
|
||||
|
||||
void reserve_stacks(size_t n) {
|
||||
void reserve_stacks(std::size_t n) {
|
||||
if constexpr(!SA::is_thread_safe) {
|
||||
std::lock_guard<std::mutex> l{p_lock};
|
||||
p_stacks.reserve(n);
|
||||
|
@ -595,7 +596,7 @@ public:
|
|||
p_stacks.deallocate(st);
|
||||
}
|
||||
|
||||
void reserve_stacks(size_t n) {
|
||||
void reserve_stacks(std::size_t n) {
|
||||
p_stacks.reserve(n);
|
||||
}
|
||||
|
||||
|
@ -720,7 +721,7 @@ public:
|
|||
* @param[in] sa The provided stack allocator.
|
||||
*/
|
||||
basic_coroutine_scheduler(
|
||||
size_t thrs = std::thread::hardware_concurrency(), SA &&sa = SA{}
|
||||
std::size_t thrs = std::thread::hardware_concurrency(), SA &&sa = SA{}
|
||||
):
|
||||
p_threads(thrs), p_stacks(std::move(sa))
|
||||
{}
|
||||
|
@ -830,7 +831,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void reserve_stacks(size_t n) {
|
||||
void reserve_stacks(std::size_t n) {
|
||||
if constexpr(!SA::is_thread_safe) {
|
||||
std::lock_guard<std::mutex> l{p_lock};
|
||||
p_stacks.reserve(n);
|
||||
|
@ -862,13 +863,13 @@ private:
|
|||
}
|
||||
|
||||
void init() {
|
||||
size_t size = p_threads;
|
||||
std::size_t size = p_threads;
|
||||
std::vector<std::thread> thrs;
|
||||
thrs.reserve(size);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
thrs.emplace_back([this]() { thread_run(); });
|
||||
}
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
if (thrs[i].joinable()) {
|
||||
thrs[i].join();
|
||||
}
|
||||
|
@ -951,7 +952,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
size_t p_threads;
|
||||
std::size_t p_threads;
|
||||
std::condition_variable p_cond;
|
||||
std::mutex p_lock;
|
||||
SA p_stacks;
|
||||
|
@ -1019,7 +1020,7 @@ inline generator<T> make_generator(F &&func) {
|
|||
return detail::current_scheduler->make_generator<T>(std::forward<F>(func));
|
||||
}
|
||||
|
||||
inline void reserve_stacks(size_t n) {
|
||||
inline void reserve_stacks(std::size_t n) {
|
||||
detail::current_scheduler->reserve_stacks(n);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#ifndef OSTD_CONTEXT_STACK_HH
|
||||
#define OSTD_CONTEXT_STACK_HH
|
||||
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -48,7 +49,7 @@ namespace ostd {
|
|||
*/
|
||||
struct stack_context {
|
||||
void *ptr = nullptr; ///< The stack pointer.
|
||||
size_t size = 0; ///< The stack size.
|
||||
std::size_t size = 0; ///< The stack size.
|
||||
#ifdef OSTD_USE_VALGRIND
|
||||
int valgrind_id = 0;
|
||||
#endif
|
||||
|
@ -75,7 +76,7 @@ struct OSTD_EXPORT stack_traits {
|
|||
* some other value too. Stack sizes are typically a multiple of page
|
||||
* size.
|
||||
*/
|
||||
static size_t page_size() noexcept;
|
||||
static std::size_t page_size() noexcept;
|
||||
|
||||
/** @brief Gets the minimum size a stack can have.
|
||||
*
|
||||
|
@ -85,7 +86,7 @@ struct OSTD_EXPORT stack_traits {
|
|||
*
|
||||
* @see maximum_size(), default_size()
|
||||
*/
|
||||
static size_t minimum_size() noexcept;
|
||||
static std::size_t minimum_size() noexcept;
|
||||
|
||||
/** @brief Gets the maximum size a stack can have.
|
||||
*
|
||||
|
@ -95,7 +96,7 @@ struct OSTD_EXPORT stack_traits {
|
|||
*
|
||||
* @see minimum_size(), default_size()
|
||||
*/
|
||||
static size_t maximum_size() noexcept;
|
||||
static std::size_t maximum_size() noexcept;
|
||||
|
||||
/** @brief Gets the default size for stacks.
|
||||
*
|
||||
|
@ -105,14 +106,14 @@ struct OSTD_EXPORT stack_traits {
|
|||
*
|
||||
* @see minimum_size(), maximum_size()
|
||||
*/
|
||||
static size_t default_size() noexcept;
|
||||
static std::size_t default_size() noexcept;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
OSTD_EXPORT void *stack_alloc(size_t sz);
|
||||
OSTD_EXPORT void stack_free(void *p, size_t sz) noexcept;
|
||||
OSTD_EXPORT void stack_protect(void *p, size_t sz) noexcept;
|
||||
OSTD_EXPORT size_t stack_main_size() noexcept;
|
||||
OSTD_EXPORT void *stack_alloc(std::size_t sz);
|
||||
OSTD_EXPORT void stack_free(void *p, std::size_t sz) noexcept;
|
||||
OSTD_EXPORT void stack_protect(void *p, std::size_t sz) noexcept;
|
||||
OSTD_EXPORT std::size_t stack_main_size() noexcept;
|
||||
}
|
||||
|
||||
/** @brief A fixed size stack.
|
||||
|
@ -159,7 +160,7 @@ struct basic_fixedsize_stack {
|
|||
* The provided argument is the size used for the stacks. It defaults
|
||||
* to the default size used for the stacks according to the traits.
|
||||
*/
|
||||
basic_fixedsize_stack(size_t ss = Traits::default_size()) noexcept:
|
||||
basic_fixedsize_stack(std::size_t ss = Traits::default_size()) noexcept:
|
||||
p_size(
|
||||
Traits::is_unbounded()
|
||||
? std::max(ss, Traits::minimum_size())
|
||||
|
@ -169,10 +170,10 @@ struct basic_fixedsize_stack {
|
|||
|
||||
/** @brief Allocates a stack. */
|
||||
stack_context allocate() {
|
||||
size_t ss = p_size;
|
||||
std::size_t ss = p_size;
|
||||
|
||||
size_t pgs = Traits::page_size();
|
||||
size_t asize = ss + pgs - 1 - (ss - 1) % pgs + (pgs * Protected);
|
||||
std::size_t pgs = Traits::page_size();
|
||||
std::size_t asize = ss + pgs - 1 - (ss - 1) % pgs + (pgs * Protected);
|
||||
|
||||
void *p = detail::stack_alloc(asize);
|
||||
if constexpr(Protected) {
|
||||
|
@ -207,7 +208,7 @@ struct basic_fixedsize_stack {
|
|||
* stacks can be reserved ahead of time. This allocates only one stack
|
||||
* at a time, so this function does nothing.
|
||||
*/
|
||||
void reserve(size_t) {}
|
||||
void reserve(std::size_t) {}
|
||||
|
||||
/** @brief Gets the allocator for stack pool uses.
|
||||
*
|
||||
|
@ -220,7 +221,7 @@ struct basic_fixedsize_stack {
|
|||
}
|
||||
|
||||
private:
|
||||
size_t p_size;
|
||||
std::size_t p_size;
|
||||
};
|
||||
|
||||
/** @brief An unprotected fixed size stack using ostd::stack_traits. */
|
||||
|
@ -270,7 +271,7 @@ private:
|
|||
|
||||
public:
|
||||
/** @brief The default number of stacks to store in each chunk. */
|
||||
static constexpr size_t DEFAULT_CHUNK_SIZE = 32;
|
||||
static constexpr std::size_t DEFAULT_CHUNK_SIZE = 32;
|
||||
|
||||
/** @brief The traits type used for the stacks. */
|
||||
using traits_type = Traits;
|
||||
|
@ -303,11 +304,12 @@ public:
|
|||
* @param cs The number of stacks in each chunk.
|
||||
*/
|
||||
basic_stack_pool(
|
||||
size_t ss = Traits::default_size(), size_t cs = DEFAULT_CHUNK_SIZE
|
||||
std::size_t ss = Traits::default_size(),
|
||||
std::size_t cs = DEFAULT_CHUNK_SIZE
|
||||
) {
|
||||
/* precalculate the sizes */
|
||||
size_t pgs = Traits::page_size();
|
||||
size_t asize = ss + pgs - 1 - (ss - 1) % pgs + (pgs * Protected);
|
||||
std::size_t pgs = Traits::page_size();
|
||||
std::size_t asize = ss + pgs - 1 - (ss - 1) % pgs + (pgs * Protected);
|
||||
p_stacksize = asize;
|
||||
p_chunksize = cs * asize;
|
||||
}
|
||||
|
@ -347,8 +349,8 @@ public:
|
|||
|
||||
/** @brief Destroys the stack pool and all memory managed by it. */
|
||||
~basic_stack_pool() {
|
||||
size_t ss = p_stacksize;
|
||||
size_t cs = p_chunksize;
|
||||
std::size_t ss = p_stacksize;
|
||||
std::size_t cs = p_chunksize;
|
||||
void *pc = p_chunk;
|
||||
while (pc) {
|
||||
void *p = pc;
|
||||
|
@ -363,12 +365,12 @@ public:
|
|||
* to contain. If it already contains that number or more, this function
|
||||
* does nothing. Otherwise it potentially reserves some extra chunks.
|
||||
*/
|
||||
void reserve(size_t n) {
|
||||
size_t cap = p_capacity;
|
||||
void reserve(std::size_t n) {
|
||||
std::size_t cap = p_capacity;
|
||||
if (n <= cap) {
|
||||
return;
|
||||
}
|
||||
size_t cnum = p_chunksize / p_stacksize;
|
||||
std::size_t cnum = p_chunksize / p_stacksize;
|
||||
p_unused = alloc_chunks(p_unused, (n - cap + cnum - 1) / cnum);
|
||||
}
|
||||
|
||||
|
@ -380,7 +382,7 @@ public:
|
|||
*/
|
||||
stack_context allocate() {
|
||||
stack_node *nd = request();
|
||||
size_t ss = p_stacksize - sizeof(stack_node);
|
||||
std::size_t ss = p_stacksize - sizeof(stack_node);
|
||||
auto *p = reinterpret_cast<unsigned char *>(nd) - ss;
|
||||
if constexpr(Protected) {
|
||||
detail::stack_protect(p, Traits::page_size());
|
||||
|
@ -436,15 +438,15 @@ private:
|
|||
stack_node *next;
|
||||
};
|
||||
|
||||
stack_node *alloc_chunks(stack_node *un, size_t n) {
|
||||
size_t ss = p_stacksize;
|
||||
size_t cs = p_chunksize;
|
||||
size_t cnum = cs / ss;
|
||||
stack_node *alloc_chunks(stack_node *un, std::size_t n) {
|
||||
std::size_t ss = p_stacksize;
|
||||
std::size_t cs = p_chunksize;
|
||||
std::size_t cnum = cs / ss;
|
||||
|
||||
for (size_t ci = 0; ci < n; ++ci) {
|
||||
for (std::size_t ci = 0; ci < n; ++ci) {
|
||||
void *chunk = detail::stack_alloc(cs);
|
||||
stack_node *prevn = un;
|
||||
for (size_t i = cnum; i >= 2; --i) {
|
||||
for (std::size_t i = cnum; i >= 2; --i) {
|
||||
auto nd = get_node(chunk, ss, i);
|
||||
nd->next_chunk = nullptr;
|
||||
nd->next = prevn;
|
||||
|
@ -473,7 +475,7 @@ private:
|
|||
return r;
|
||||
}
|
||||
|
||||
stack_node *get_node(void *chunk, size_t ssize, size_t n) {
|
||||
stack_node *get_node(void *chunk, std::size_t ssize, std::size_t n) {
|
||||
return reinterpret_cast<stack_node *>(
|
||||
static_cast<unsigned char *>(chunk) + (ssize * n) - sizeof(stack_node)
|
||||
);
|
||||
|
@ -482,9 +484,9 @@ private:
|
|||
void *p_chunk = nullptr;
|
||||
stack_node *p_unused = nullptr;
|
||||
|
||||
size_t p_chunksize;
|
||||
size_t p_stacksize;
|
||||
size_t p_capacity = 0;
|
||||
std::size_t p_chunksize;
|
||||
std::size_t p_stacksize;
|
||||
std::size_t p_capacity = 0;
|
||||
};
|
||||
|
||||
/** @brief Swaps two stack pools. */
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#ifndef OSTD_COROUTINE_HH
|
||||
#define OSTD_COROUTINE_HH
|
||||
|
||||
#include <cstddef>
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
#include <typeinfo>
|
||||
|
@ -65,7 +66,7 @@ namespace detail {
|
|||
|
||||
extern "C" OSTD_EXPORT
|
||||
fcontext_t OSTD_CDECL ostd_make_fcontext(
|
||||
void *sp, size_t size, void (*fn)(transfer_t)
|
||||
void *sp, std::size_t size, void (*fn)(transfer_t)
|
||||
);
|
||||
|
||||
extern "C" OSTD_EXPORT
|
||||
|
@ -267,7 +268,7 @@ protected:
|
|||
p_stack = sa.allocate();
|
||||
|
||||
void *sp = get_stack_ptr<SA>();
|
||||
size_t asize = p_stack.size - (
|
||||
std::size_t asize = p_stack.size - (
|
||||
static_cast<unsigned char *>(p_stack.ptr) -
|
||||
static_cast<unsigned char *>(sp)
|
||||
);
|
||||
|
@ -282,14 +283,14 @@ private:
|
|||
template<typename SA>
|
||||
void *get_stack_ptr() {
|
||||
/* 16 byte stack pointer alignment */
|
||||
constexpr size_t salign = 16;
|
||||
constexpr std::size_t salign = 16;
|
||||
/* makes enough space so that we can store the allocator at
|
||||
* stack pointer location (we'll need it for dealloc later)
|
||||
*/
|
||||
constexpr size_t sasize = sizeof(SA);
|
||||
constexpr std::size_t sasize = sizeof(SA);
|
||||
|
||||
void *sp = static_cast<unsigned char *>(p_stack.ptr) - sasize - salign;
|
||||
size_t space = sasize + salign;
|
||||
std::size_t space = sasize + salign;
|
||||
sp = std::align(salign, sasize, sp, space);
|
||||
|
||||
return sp;
|
||||
|
@ -1203,8 +1204,8 @@ struct generator_range: input_range<generator_range<T>> {
|
|||
using range_category = input_range_tag;
|
||||
using value_type = T;
|
||||
using reference = T &;
|
||||
using size_type = size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
/** Generator ranges are not default constructible. */
|
||||
generator_range() = delete;
|
||||
|
|
|
@ -21,9 +21,8 @@
|
|||
#include "ostd/platform.hh"
|
||||
#include "ostd/internal/win32.hh"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
|
||||
|
@ -50,27 +49,11 @@ namespace ostd {
|
|||
inline std::optional<std::string> env_get(string_range name) {
|
||||
char buf[256];
|
||||
auto tbuf = to_temp_cstr(name, buf, sizeof(buf));
|
||||
#ifndef OSTD_PLATFORM_WIN32
|
||||
char const *ret = getenv(tbuf.get());
|
||||
char const *ret = std::getenv(tbuf.get());
|
||||
if (!ret) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return std::string{ret};
|
||||
#else
|
||||
std::vector<char> rbuf;
|
||||
DWORD sz;
|
||||
for (;;) {
|
||||
sz = GetEnvironmentVariable(tbuf.get(), rbuf.data(), rbuf.capacity());
|
||||
if (!sz) {
|
||||
return std::nullopt;
|
||||
}
|
||||
if (sz < rbuf.capacity()) {
|
||||
break;
|
||||
}
|
||||
rbuf.reserve(sz);
|
||||
}
|
||||
return std::string{rbuf.data(), sz};
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @brief Sets an environment variable.
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#ifndef OSTD_EVENT_HH
|
||||
#define OSTD_EVENT_HH
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
|
@ -22,7 +23,7 @@ namespace detail {
|
|||
using func_t = std::function<void(C &, A...)>;
|
||||
auto *bufp = new unsigned char[sizeof(func_t) * p_nfuncs];
|
||||
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
||||
for (size_t i = 0; i < p_nfuncs; ++i)
|
||||
for (std::size_t i = 0; i < p_nfuncs; ++i)
|
||||
new (&nbuf[i]) func_t(ev.p_funcs[i]);
|
||||
p_funcs = nbuf;
|
||||
}
|
||||
|
@ -39,7 +40,7 @@ namespace detail {
|
|||
p_nfuncs = ev.p_nfuncs;
|
||||
auto *bufp = new unsigned char[sizeof(func_t) * p_nfuncs];
|
||||
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
||||
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||
for (std::size_t i = 0; i < p_nfuncs; ++i) {
|
||||
new (&nbuf[i]) func_t(ev.p_funcs[i]);
|
||||
}
|
||||
p_funcs = nbuf;
|
||||
|
@ -54,7 +55,7 @@ namespace detail {
|
|||
~signal_base() { clear(); }
|
||||
|
||||
void clear() {
|
||||
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||
for (std::size_t i = 0; i < p_nfuncs; ++i) {
|
||||
using func = std::function<void(C &, A...)>;
|
||||
p_funcs[i].~func();
|
||||
}
|
||||
|
@ -64,9 +65,9 @@ namespace detail {
|
|||
}
|
||||
|
||||
template<typename F>
|
||||
size_t connect(F &&func) {
|
||||
std::size_t connect(F &&func) {
|
||||
using func_t = std::function<void(C &, A...)>;
|
||||
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||
for (std::size_t i = 0; i < p_nfuncs; ++i) {
|
||||
if (!p_funcs[i]) {
|
||||
p_funcs[i] = std::forward<F>(func);
|
||||
return i;
|
||||
|
@ -74,7 +75,7 @@ namespace detail {
|
|||
}
|
||||
auto *bufp = new unsigned char[sizeof(func_t) * (p_nfuncs + 1)];
|
||||
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
||||
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||
for (std::size_t i = 0; i < p_nfuncs; ++i) {
|
||||
new (&nbuf[i]) func_t(std::move(p_funcs[i]));
|
||||
p_funcs[i].~func_t();
|
||||
}
|
||||
|
@ -84,7 +85,7 @@ namespace detail {
|
|||
return p_nfuncs++;
|
||||
}
|
||||
|
||||
bool disconnect(size_t idx) {
|
||||
bool disconnect(std::size_t idx) {
|
||||
if ((idx >= p_nfuncs) || !p_funcs[idx]) {
|
||||
return false;
|
||||
}
|
||||
|
@ -97,7 +98,7 @@ namespace detail {
|
|||
if (!p_class) {
|
||||
return;
|
||||
}
|
||||
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||
for (std::size_t i = 0; i < p_nfuncs; ++i) {
|
||||
if (p_funcs[i]) {
|
||||
p_funcs[i](*p_class, args...);
|
||||
}
|
||||
|
@ -124,7 +125,7 @@ namespace detail {
|
|||
private:
|
||||
C *p_class;
|
||||
std::function<void(C &, A...)> *p_funcs;
|
||||
size_t p_nfuncs;
|
||||
std::size_t p_nfuncs;
|
||||
};
|
||||
} /* namespace detail */
|
||||
|
||||
|
@ -151,9 +152,9 @@ public:
|
|||
void clear() { p_base.clear(); }
|
||||
|
||||
template<typename F>
|
||||
size_t connect(F &&func) { return p_base.connect(std::forward<F>(func)); }
|
||||
std::size_t connect(F &&func) { return p_base.connect(std::forward<F>(func)); }
|
||||
|
||||
bool disconnect(size_t idx) { return p_base.disconnect(idx); }
|
||||
bool disconnect(std::size_t idx) { return p_base.disconnect(idx); }
|
||||
|
||||
template<typename ...Args>
|
||||
void emit(Args &&...args) { p_base.emit(std::forward<Args>(args)...); }
|
||||
|
@ -190,9 +191,9 @@ public:
|
|||
void clear() { p_base.clear(); }
|
||||
|
||||
template<typename F>
|
||||
size_t connect(F &&func) { return p_base.connect(std::forward<F>(func)); }
|
||||
std::size_t connect(F &&func) { return p_base.connect(std::forward<F>(func)); }
|
||||
|
||||
bool disconnect(size_t idx) { return p_base.disconnect(idx); }
|
||||
bool disconnect(std::size_t idx) { return p_base.disconnect(idx); }
|
||||
|
||||
template<typename ...Args>
|
||||
void emit(Args &&...args) const { p_base.emit(std::forward<Args>(args)...); }
|
||||
|
|
|
@ -17,11 +17,8 @@
|
|||
#ifndef OSTD_FORMAT_HH
|
||||
#define OSTD_FORMAT_HH
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <cmath>
|
||||
|
||||
#include <cstddef>
|
||||
#include <climits>
|
||||
#include <utility>
|
||||
#include <stdexcept>
|
||||
#include <locale>
|
||||
|
@ -111,8 +108,8 @@ namespace detail {
|
|||
return ret;
|
||||
}
|
||||
|
||||
inline size_t read_digits(string_range &fmt, char *buf) {
|
||||
size_t ret = 0;
|
||||
inline std::size_t read_digits(string_range &fmt, char *buf) {
|
||||
std::size_t ret = 0;
|
||||
for (; !fmt.empty() && isdigit(fmt.front()); ++ret) {
|
||||
*buf++ = fmt.front();
|
||||
fmt.pop_front();
|
||||
|
@ -176,7 +173,7 @@ namespace detail {
|
|||
|
||||
inline char const *escape_fmt_char(char v, char quote) {
|
||||
if ((v >= 0 && v < 0x20) || (v == quote)) {
|
||||
return fmt_escapes[size_t(v)];
|
||||
return fmt_escapes[std::size_t(v)];
|
||||
} else if (v == 0x7F) {
|
||||
return "\\x7F";
|
||||
}
|
||||
|
@ -185,7 +182,7 @@ namespace detail {
|
|||
|
||||
/* retrieve width/precision */
|
||||
template<typename T, typename ...A>
|
||||
inline int get_arg_param(size_t idx, T const &val, A const &...args) {
|
||||
inline int get_arg_param(std::size_t idx, T const &val, A const &...args) {
|
||||
if (idx) {
|
||||
if constexpr(!sizeof...(A)) {
|
||||
throw format_error{"not enough format args"};
|
||||
|
@ -414,8 +411,8 @@ namespace detail {
|
|||
* allowed.
|
||||
* * Pointers are formatted then. If the `s` specifier is used, the pointer
|
||||
* will be formatted as hex with the `0x` prefix. Otherwise it's converted
|
||||
* to `size_t` and formatted with the specifier (might error depending on
|
||||
* the specifier).
|
||||
* to `std::size_t` and formatted with the specifier (might error depending
|
||||
* on the specifier).
|
||||
* * Then integers are formatted. Using the `s` specifier is like using the
|
||||
* `d` specifier.
|
||||
* * Floats follow. Using `s` is like using `g`.
|
||||
|
@ -623,7 +620,7 @@ struct format_spec {
|
|||
* @see set_width(), set_precision_arg();
|
||||
*/
|
||||
template<typename ...A>
|
||||
void set_width_arg(size_t idx, A const &...args) {
|
||||
void set_width_arg(std::size_t idx, A const &...args) {
|
||||
p_width = detail::get_arg_param(idx, args...);
|
||||
p_has_width = p_arg_width = true;
|
||||
}
|
||||
|
@ -656,7 +653,7 @@ struct format_spec {
|
|||
* @see set_precision(), set_width_arg();
|
||||
*/
|
||||
template<typename ...A>
|
||||
void set_precision_arg(size_t idx, A const &...args) {
|
||||
void set_precision_arg(std::size_t idx, A const &...args) {
|
||||
p_precision = detail::get_arg_param(idx, args...);
|
||||
p_has_precision = p_arg_precision = true;
|
||||
}
|
||||
|
@ -861,7 +858,7 @@ private:
|
|||
}
|
||||
|
||||
bool read_spec() {
|
||||
size_t ndig = detail::read_digits(p_fmt, p_buf);
|
||||
std::size_t ndig = detail::read_digits(p_fmt, p_buf);
|
||||
|
||||
bool havepos = false;
|
||||
p_index = 0;
|
||||
|
@ -877,11 +874,11 @@ private:
|
|||
|
||||
/* parse flags */
|
||||
p_flags = p_gflags;
|
||||
size_t skipd = 0;
|
||||
std::size_t skipd = 0;
|
||||
if (havepos || !ndig) {
|
||||
p_flags |= detail::parse_fmt_flags(p_fmt, 0);
|
||||
} else {
|
||||
for (size_t i = 0; i < ndig; ++i) {
|
||||
for (std::size_t i = 0; i < ndig; ++i) {
|
||||
if (p_buf[i] != '0') {
|
||||
break;
|
||||
}
|
||||
|
@ -944,7 +941,9 @@ private:
|
|||
}
|
||||
|
||||
template<typename R>
|
||||
void write_spaces(R &writer, size_t n, bool left, char c = ' ') const {
|
||||
void write_spaces(
|
||||
R &writer, std::size_t n, bool left, char c = ' '
|
||||
) const {
|
||||
if (left == bool(p_flags & FMT_FLAG_DASH)) {
|
||||
return;
|
||||
}
|
||||
|
@ -954,14 +953,14 @@ private:
|
|||
/* string base writer */
|
||||
template<typename R>
|
||||
void write_str(R &writer, bool escape, string_range val) const {
|
||||
size_t n = val.size();
|
||||
std::size_t n = val.size();
|
||||
if (has_precision()) {
|
||||
n = std::min(n, size_t(precision()));
|
||||
n = std::min(n, std::size_t(precision()));
|
||||
}
|
||||
write_spaces(writer, n, true);
|
||||
if (escape) {
|
||||
writer.put('"');
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
for (std::size_t i = 0; i < n; ++i) {
|
||||
if (val.empty()) {
|
||||
break;
|
||||
}
|
||||
|
@ -989,7 +988,7 @@ private:
|
|||
if (esc) {
|
||||
char buf[6];
|
||||
buf[0] = '\'';
|
||||
size_t elen = strlen(esc);
|
||||
std::size_t elen = strlen(esc);
|
||||
memcpy(buf + 1, esc, elen);
|
||||
buf[elen + 1] = '\'';
|
||||
write_val(writer, false, ostd::string_range{
|
||||
|
@ -1013,7 +1012,7 @@ private:
|
|||
void write_int(R &writer, bool ptr, bool neg, T val) const {
|
||||
/* binary representation is the biggest, assume grouping */
|
||||
char buf[sizeof(T) * CHAR_BIT * 2];
|
||||
size_t n = 0;
|
||||
std::size_t n = 0;
|
||||
|
||||
char isp = spec();
|
||||
if (isp == 's') {
|
||||
|
@ -1053,11 +1052,11 @@ private:
|
|||
T vb = val % base;
|
||||
buf[n++] = (vb + "70"[vb < 10]) | cmask;
|
||||
}
|
||||
size_t tn = n;
|
||||
std::size_t tn = n;
|
||||
if (has_precision()) {
|
||||
int prec = precision();
|
||||
if (size_t(prec) > tn) {
|
||||
tn = size_t(prec);
|
||||
if (std::size_t(prec) > tn) {
|
||||
tn = std::size_t(prec);
|
||||
} else if (!prec && zval) {
|
||||
tn = 0;
|
||||
}
|
||||
|
@ -1088,10 +1087,10 @@ private:
|
|||
write_spaces(writer, tn + (!!pfx * 2) + sign, true, '0');
|
||||
}
|
||||
if (tn) {
|
||||
for (size_t i = 0; i < (tn - n); ++i) {
|
||||
for (std::size_t i = 0; i < (tn - n); ++i) {
|
||||
writer.put('0');
|
||||
}
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
for (std::size_t i = 0; i < n; ++i) {
|
||||
writer.put(buf[n - i - 1]);
|
||||
}
|
||||
}
|
||||
|
@ -1209,7 +1208,7 @@ private:
|
|||
* char pointers are handled by the string case above
|
||||
*/
|
||||
if constexpr(std::is_pointer_v<T>) {
|
||||
write_int(writer, (spec() == 's'), false, size_t(val));
|
||||
write_int(writer, (spec() == 's'), false, std::size_t(val));
|
||||
return;
|
||||
}
|
||||
/* integers */
|
||||
|
@ -1239,7 +1238,7 @@ private:
|
|||
/* actual writer */
|
||||
template<typename R, typename T, typename ...A>
|
||||
void write_arg(
|
||||
R &writer, size_t idx, T const &val, A const &...args
|
||||
R &writer, std::size_t idx, T const &val, A const &...args
|
||||
) const {
|
||||
if (idx) {
|
||||
if constexpr(!sizeof...(A)) {
|
||||
|
@ -1302,7 +1301,7 @@ private:
|
|||
/* range writer */
|
||||
template<typename R, typename T, typename ...A>
|
||||
void write_range(
|
||||
R &writer, size_t idx, bool expandval, string_range sep,
|
||||
R &writer, std::size_t idx, bool expandval, string_range sep,
|
||||
T const &val, A const &...args
|
||||
) const {
|
||||
if (idx) {
|
||||
|
@ -1323,7 +1322,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
template<size_t I, size_t N, typename R, typename T>
|
||||
template<std::size_t I, std::size_t N, typename R, typename T>
|
||||
void write_tuple_val(
|
||||
R &writer, bool escape, string_range sep, T const &tup
|
||||
) const {
|
||||
|
@ -1337,7 +1336,7 @@ private:
|
|||
|
||||
template<typename R, typename T, typename ...A>
|
||||
void write_tuple(
|
||||
R &writer, size_t idx, T const &val, A const &...args
|
||||
R &writer, std::size_t idx, T const &val, A const &...args
|
||||
) {
|
||||
if (idx) {
|
||||
if constexpr(!sizeof...(A)) {
|
||||
|
@ -1358,9 +1357,9 @@ private:
|
|||
|
||||
template<typename R, typename ...A>
|
||||
void write_fmt(R &writer, A const &...args) {
|
||||
size_t argidx = 1;
|
||||
std::size_t argidx = 1;
|
||||
while (read_until_spec(writer)) {
|
||||
size_t argpos = index();
|
||||
std::size_t argpos = index();
|
||||
if (is_nested()) {
|
||||
if (!argpos) {
|
||||
argpos = argidx++;
|
||||
|
@ -1398,7 +1397,7 @@ private:
|
|||
set_precision_arg(argpos - 2, args...);
|
||||
}
|
||||
if (arg_width()) {
|
||||
if (argpos <= (size_t(argprec) + 1)) {
|
||||
if (argpos <= (std::size_t(argprec) + 1)) {
|
||||
throw format_error{"argument width not given"};
|
||||
}
|
||||
set_width_arg(argpos - 2 - argprec, args...);
|
||||
|
@ -1440,7 +1439,9 @@ private:
|
|||
|
||||
template<typename R>
|
||||
struct fmt_num_put final: std::num_put<char, fmt_out<R>> {
|
||||
fmt_num_put(size_t refs = 0): std::num_put<char, fmt_out<R>>(refs) {}
|
||||
fmt_num_put(std::size_t refs = 0):
|
||||
std::num_put<char, fmt_out<R>>(refs)
|
||||
{}
|
||||
~fmt_num_put() {}
|
||||
};
|
||||
|
||||
|
|
|
@ -145,8 +145,8 @@ struct generic_condvar {
|
|||
}
|
||||
|
||||
private:
|
||||
static constexpr size_t cvars = sizeof(std::condition_variable);
|
||||
static constexpr size_t icvars =
|
||||
static constexpr auto cvars = sizeof(std::condition_variable);
|
||||
static constexpr auto icvars =
|
||||
sizeof(detail::cond_impl<std::condition_variable>);
|
||||
std::aligned_storage_t<std::max(
|
||||
6 * sizeof(void *) + (icvars - cvars), icvars
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#ifndef OSTD_IO_HH
|
||||
#define OSTD_IO_HH
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cerrno>
|
||||
|
||||
|
@ -203,7 +204,7 @@ struct OSTD_EXPORT file_stream: stream {
|
|||
*
|
||||
* @see write_bytes()
|
||||
*/
|
||||
size_t read_bytes(void *buf, size_t count);
|
||||
std::size_t read_bytes(void *buf, std::size_t count);
|
||||
|
||||
/** @brief Writes `count` bytes into the stream.
|
||||
*
|
||||
|
@ -211,7 +212,7 @@ struct OSTD_EXPORT file_stream: stream {
|
|||
*
|
||||
* @see read_bytes()
|
||||
*/
|
||||
void write_bytes(void const *buf, size_t count);
|
||||
void write_bytes(void const *buf, std::size_t count);
|
||||
|
||||
/** @brief Reads a single character from the stream.
|
||||
*
|
||||
|
@ -280,8 +281,8 @@ namespace detail {
|
|||
struct stdout_range: output_range<stdout_range> {
|
||||
using value_type = char;
|
||||
using reference = char &;
|
||||
using size_type = size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
stdout_range() {}
|
||||
void put(char c) {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef OSTD_PLATFORM_HH
|
||||
#define OSTD_PLATFORM_HH
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include <type_traits>
|
||||
|
@ -278,7 +278,10 @@ inline std::uint64_t endian_swap64(std::uint64_t x) noexcept {
|
|||
|
||||
/* endian swap */
|
||||
|
||||
template<typename T, size_t N = sizeof(T), bool IsNum = std::is_arithmetic_v<T>>
|
||||
template<
|
||||
typename T, std::size_t N = sizeof(T),
|
||||
bool IsNum = std::is_arithmetic_v<T>
|
||||
>
|
||||
struct endian_swap;
|
||||
|
||||
template<typename T>
|
||||
|
|
|
@ -6,9 +6,7 @@
|
|||
#ifndef OSTD_RANGE_HH
|
||||
#define OSTD_RANGE_HH
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
@ -273,7 +271,7 @@ inline range_size_t<IR> range_pop_front_n(IR &range, range_size_t<IR> n) {
|
|||
range = range.slice(n, rs);
|
||||
return n;
|
||||
} else {
|
||||
size_t r = 0;
|
||||
range_size_t<IR> r = 0;
|
||||
while (n-- && !range.empty()) {
|
||||
range.pop_front();
|
||||
++r;
|
||||
|
@ -292,7 +290,7 @@ inline range_size_t<IR> range_pop_back_n(IR &range, range_size_t<IR> n) {
|
|||
range = range.slice(0, rs - n);
|
||||
return n;
|
||||
} else {
|
||||
size_t r = 0;
|
||||
range_size_t<IR> r = 0;
|
||||
while (n-- && !range.empty()) {
|
||||
range.pop_back();
|
||||
++r;
|
||||
|
@ -404,8 +402,8 @@ template<typename T>
|
|||
struct noop_output_range: output_range<noop_output_range<T>> {
|
||||
using value_type = T;
|
||||
using reference = T &;
|
||||
using size_type = size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
void put(T const &) {}
|
||||
};
|
||||
|
@ -694,8 +692,8 @@ struct number_range: input_range<number_range<T>> {
|
|||
using range_category = forward_range_tag;
|
||||
using value_type = T;
|
||||
using reference = T;
|
||||
using size_type = size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
number_range() = delete;
|
||||
number_range(T a, T b, T step = T(1)):
|
||||
|
@ -882,7 +880,7 @@ public:
|
|||
};
|
||||
|
||||
namespace detail {
|
||||
template<size_t I, size_t N, typename T>
|
||||
template<std::size_t I, std::size_t N, typename T>
|
||||
inline void join_range_pop(T &tup) {
|
||||
if constexpr(I != N) {
|
||||
if (!std::get<I>(tup).empty()) {
|
||||
|
@ -893,7 +891,7 @@ namespace detail {
|
|||
}
|
||||
}
|
||||
|
||||
template<size_t I, size_t N, typename T>
|
||||
template<std::size_t I, std::size_t N, typename T>
|
||||
inline auto join_range_front(T &tup) {
|
||||
if constexpr(I != N) {
|
||||
if (!std::get<I>(tup).empty()) {
|
||||
|
@ -1051,8 +1049,8 @@ struct appender_range: output_range<appender_range<T>> {
|
|||
void clear() { p_data.clear(); }
|
||||
bool empty() const { return p_data.empty(); }
|
||||
|
||||
void reserve(typename T::size_type cap) { p_data.reserve(cap); }
|
||||
void resize(typename T::size_type len) { p_data.resize(len); }
|
||||
void reserve(size_type cap) { p_data.reserve(cap); }
|
||||
void resize(size_type len) { p_data.resize(len); }
|
||||
|
||||
size_type size() const { return p_data.size(); }
|
||||
size_type capacity() const { return p_data.capacity(); }
|
||||
|
@ -1245,7 +1243,7 @@ iterator_range<T const *> citer(std::initializer_list<T> init) noexcept {
|
|||
return iterator_range<T const *>(init.begin(), init.end());
|
||||
}
|
||||
|
||||
template<typename T, size_t N>
|
||||
template<typename T, std::size_t N>
|
||||
struct ranged_traits<T[N]> {
|
||||
using range = iterator_range<T *>;
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#ifndef OSTD_STREAM_HH
|
||||
#define OSTD_STREAM_HH
|
||||
|
||||
#include <cstddef>
|
||||
#include <cerrno>
|
||||
#include <cstdlib>
|
||||
#include <type_traits>
|
||||
|
@ -223,7 +224,7 @@ struct stream {
|
|||
*
|
||||
* @see write_bytes(), get_char(), get(), get_line()
|
||||
*/
|
||||
virtual size_t read_bytes(void *, size_t) {
|
||||
virtual std::size_t read_bytes(void *, std::size_t) {
|
||||
throw stream_error{EINVAL, std::generic_category()};
|
||||
}
|
||||
|
||||
|
@ -244,7 +245,7 @@ struct stream {
|
|||
*
|
||||
* @see read_bytes(), put_char(), put(), write()
|
||||
*/
|
||||
virtual void write_bytes(void const *, size_t) {
|
||||
virtual void write_bytes(void const *, std::size_t) {
|
||||
throw stream_error{EINVAL, std::generic_category()};
|
||||
}
|
||||
|
||||
|
@ -429,7 +430,7 @@ struct stream {
|
|||
* @throws ostd::stream_error on write failure.
|
||||
*/
|
||||
template<typename T>
|
||||
void put(T const *v, size_t count) {
|
||||
void put(T const *v, std::size_t count) {
|
||||
write_bytes(v, count * sizeof(T));
|
||||
}
|
||||
|
||||
|
@ -456,7 +457,7 @@ struct stream {
|
|||
* @throws ostd::stream_error on read failure.
|
||||
*/
|
||||
template<typename T>
|
||||
size_t get(T *v, size_t count) {
|
||||
std::size_t get(T *v, std::size_t count) {
|
||||
/* if eof was reached, at least return how many values succeeded */
|
||||
return read_bytes(v, count * sizeof(T)) / sizeof(T);
|
||||
}
|
||||
|
@ -556,7 +557,7 @@ struct stream_range<T, true>: input_range<stream_range<T>> {
|
|||
using range_category = input_range_tag;
|
||||
using value_type = T;
|
||||
using reference = T;
|
||||
using size_type = size_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = stream_off_t;
|
||||
|
||||
/** @brief Stream ranges are not default constructible. */
|
||||
|
@ -670,7 +671,7 @@ struct stream_line_range: input_range<stream_line_range<T, TC>> {
|
|||
using range_category = input_range_tag;
|
||||
using value_type = TC;
|
||||
using reference = TC &;
|
||||
using size_type = size_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = stream_off_t;
|
||||
|
||||
/** @brief Stream line ranges are not default constructible. */
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
#ifndef OSTD_STRING_HH
|
||||
#define OSTD_STRING_HH
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
@ -27,8 +25,8 @@ struct basic_char_range: input_range<basic_char_range<T>> {
|
|||
using range_category = contiguous_range_tag;
|
||||
using value_type = T;
|
||||
using reference = T &;
|
||||
using size_type = size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
private:
|
||||
struct nat {};
|
||||
|
@ -43,7 +41,7 @@ public:
|
|||
std::is_convertible_v<U, T *>, nat
|
||||
> = nat{}): p_beg(beg) {
|
||||
if constexpr(std::is_array_v<std::remove_reference_t<U>>) {
|
||||
size_t N = std::extent_v<std::remove_reference_t<U>>;
|
||||
std::size_t N = std::extent_v<std::remove_reference_t<U>>;
|
||||
p_end = beg + N - (beg[N - 1] == '\0');
|
||||
} else {
|
||||
p_end = beg + (beg ? TR::length(beg) : 0);
|
||||
|
@ -95,16 +93,16 @@ public:
|
|||
|
||||
T &back() const { return *(p_end - 1); }
|
||||
|
||||
size_t size() const { return p_end - p_beg; }
|
||||
size_type size() const { return p_end - p_beg; }
|
||||
|
||||
basic_char_range slice(size_t start, size_t end) const {
|
||||
basic_char_range slice(size_type start, size_type end) const {
|
||||
return basic_char_range(p_beg + start, p_beg + end);
|
||||
}
|
||||
basic_char_range slice(size_t start) const {
|
||||
basic_char_range slice(size_type start) const {
|
||||
return slice(start, size());
|
||||
}
|
||||
|
||||
T &operator[](size_t i) const { return p_beg[i]; }
|
||||
T &operator[](size_type i) const { return p_beg[i]; }
|
||||
|
||||
void put(T v) {
|
||||
if (p_beg == p_end) {
|
||||
|
@ -118,7 +116,7 @@ public:
|
|||
|
||||
/* non-range */
|
||||
int compare(basic_char_range<T const> s) const {
|
||||
size_t s1 = size(), s2 = s.size();
|
||||
size_type s1 = size(), s2 = s.size();
|
||||
int ret;
|
||||
if (!s1 || !s2) {
|
||||
goto diffsize;
|
||||
|
@ -131,9 +129,9 @@ diffsize:
|
|||
}
|
||||
|
||||
int case_compare(basic_char_range<T const> s) const {
|
||||
size_t s1 = size(), s2 = s.size();
|
||||
for (size_t i = 0, ms = std::min(s1, s2); i < ms; ++i) {
|
||||
int d = toupper(p_beg[i]) - toupper(s[i]);
|
||||
size_type s1 = size(), s2 = s.size();
|
||||
for (size_type i = 0, ms = std::min(s1, s2); i < ms; ++i) {
|
||||
int d = std::toupper(p_beg[i]) - std::toupper(s[i]);
|
||||
if (d) {
|
||||
return d;
|
||||
}
|
||||
|
@ -381,7 +379,7 @@ inline std::basic_string<std::remove_cv_t<range_value_t<R>>, TR, A> make_string(
|
|||
|
||||
inline namespace literals {
|
||||
inline namespace string_literals {
|
||||
inline string_range operator "" _sr(char const *str, size_t len) {
|
||||
inline string_range operator "" _sr(char const *str, std::size_t len) {
|
||||
return string_range(str, str + len);
|
||||
}
|
||||
}
|
||||
|
@ -396,12 +394,15 @@ private:
|
|||
public:
|
||||
temp_c_string() = delete;
|
||||
temp_c_string(temp_c_string const &) = delete;
|
||||
temp_c_string(temp_c_string &&s): p_buf(s.p_buf), p_allocated(s.p_allocated) {
|
||||
temp_c_string(temp_c_string &&s):
|
||||
p_buf(s.p_buf), p_allocated(s.p_allocated)
|
||||
{
|
||||
s.p_buf = nullptr;
|
||||
s.p_allocated = false;
|
||||
}
|
||||
temp_c_string(R input, std::remove_cv_t<range_value_t<R>> *sbuf, size_t bufsize)
|
||||
: p_buf(nullptr), p_allocated(false) {
|
||||
temp_c_string(
|
||||
R input, std::remove_cv_t<range_value_t<R>> *sbuf, std::size_t bufsize
|
||||
): p_buf(nullptr), p_allocated(false) {
|
||||
if (input.empty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -427,8 +428,12 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
operator std::remove_cv_t<range_value_t<R>> const *() const { return p_buf; }
|
||||
std::remove_cv_t<range_value_t<R>> const *get() const { return p_buf; }
|
||||
operator std::remove_cv_t<range_value_t<R>> const *() const {
|
||||
return p_buf;
|
||||
}
|
||||
std::remove_cv_t<range_value_t<R>> const *get() const {
|
||||
return p_buf;
|
||||
}
|
||||
|
||||
void swap(temp_c_string &s) {
|
||||