use size_t and ptrdiff_t
parent
1db7529ad9
commit
2884f4b47b
|
@ -22,7 +22,7 @@ namespace detail {
|
||||||
using func_t = std::function<void(C &, A...)>;
|
using func_t = std::function<void(C &, A...)>;
|
||||||
byte *bufp = new byte[sizeof(func_t) * p_nfuncs];
|
byte *bufp = new byte[sizeof(func_t) * p_nfuncs];
|
||||||
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
||||||
for (Size i = 0; i < p_nfuncs; ++i)
|
for (size_t i = 0; i < p_nfuncs; ++i)
|
||||||
new (&nbuf[i]) func_t(ev.p_funcs[i]);
|
new (&nbuf[i]) func_t(ev.p_funcs[i]);
|
||||||
p_funcs = nbuf;
|
p_funcs = nbuf;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ namespace detail {
|
||||||
p_nfuncs = ev.p_nfuncs;
|
p_nfuncs = ev.p_nfuncs;
|
||||||
byte *bufp = new byte[sizeof(func_t) * p_nfuncs];
|
byte *bufp = new byte[sizeof(func_t) * p_nfuncs];
|
||||||
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
||||||
for (Size i = 0; i < p_nfuncs; ++i) {
|
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||||
new (&nbuf[i]) func_t(ev.p_funcs[i]);
|
new (&nbuf[i]) func_t(ev.p_funcs[i]);
|
||||||
}
|
}
|
||||||
p_funcs = nbuf;
|
p_funcs = nbuf;
|
||||||
|
@ -54,7 +54,7 @@ namespace detail {
|
||||||
~SignalBase() { clear(); }
|
~SignalBase() { clear(); }
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
for (Size i = 0; i < p_nfuncs; ++i) {
|
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||||
using func = std::function<void(C &, A...)>;
|
using func = std::function<void(C &, A...)>;
|
||||||
p_funcs[i].~func();
|
p_funcs[i].~func();
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,9 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
Size connect(F &&func) {
|
size_t connect(F &&func) {
|
||||||
using func_t = std::function<void(C &, A...)>;
|
using func_t = std::function<void(C &, A...)>;
|
||||||
for (Size i = 0; i < p_nfuncs; ++i) {
|
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||||
if (!p_funcs[i]) {
|
if (!p_funcs[i]) {
|
||||||
p_funcs[i] = std::forward<F>(func);
|
p_funcs[i] = std::forward<F>(func);
|
||||||
return i;
|
return i;
|
||||||
|
@ -74,7 +74,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
byte *bufp = new byte[sizeof(func_t) * (p_nfuncs + 1)];
|
byte *bufp = new byte[sizeof(func_t) * (p_nfuncs + 1)];
|
||||||
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
func_t *nbuf = reinterpret_cast<func_t *>(bufp);
|
||||||
for (Size i = 0; i < p_nfuncs; ++i) {
|
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||||
new (&nbuf[i]) func_t(std::move(p_funcs[i]));
|
new (&nbuf[i]) func_t(std::move(p_funcs[i]));
|
||||||
p_funcs[i].~func_t();
|
p_funcs[i].~func_t();
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ namespace detail {
|
||||||
return p_nfuncs++;
|
return p_nfuncs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool disconnect(Size idx) {
|
bool disconnect(size_t idx) {
|
||||||
if ((idx >= p_nfuncs) || !p_funcs[idx]) {
|
if ((idx >= p_nfuncs) || !p_funcs[idx]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ namespace detail {
|
||||||
if (!p_class) {
|
if (!p_class) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Size i = 0; i < p_nfuncs; ++i) {
|
for (size_t i = 0; i < p_nfuncs; ++i) {
|
||||||
if (p_funcs[i]) {
|
if (p_funcs[i]) {
|
||||||
p_funcs[i](*p_class, args...);
|
p_funcs[i](*p_class, args...);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ namespace detail {
|
||||||
private:
|
private:
|
||||||
C *p_class;
|
C *p_class;
|
||||||
std::function<void(C &, A...)> *p_funcs;
|
std::function<void(C &, A...)> *p_funcs;
|
||||||
Size p_nfuncs;
|
size_t p_nfuncs;
|
||||||
};
|
};
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
|
@ -151,9 +151,9 @@ public:
|
||||||
void clear() { p_base.clear(); }
|
void clear() { p_base.clear(); }
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
Size connect(F &&func) { return p_base.connect(std::forward<F>(func)); }
|
size_t connect(F &&func) { return p_base.connect(std::forward<F>(func)); }
|
||||||
|
|
||||||
bool disconnect(Size idx) { return p_base.disconnect(idx); }
|
bool disconnect(size_t idx) { return p_base.disconnect(idx); }
|
||||||
|
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
void emit(Args &&...args) { p_base.emit(std::forward<Args>(args)...); }
|
void emit(Args &&...args) { p_base.emit(std::forward<Args>(args)...); }
|
||||||
|
@ -190,9 +190,9 @@ public:
|
||||||
void clear() { p_base.clear(); }
|
void clear() { p_base.clear(); }
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
Size connect(F &&func) { return p_base.connect(std::forward<F>(func)); }
|
size_t connect(F &&func) { return p_base.connect(std::forward<F>(func)); }
|
||||||
|
|
||||||
bool disconnect(Size idx) { return p_base.disconnect(idx); }
|
bool disconnect(size_t idx) { return p_base.disconnect(idx); }
|
||||||
|
|
||||||
template<typename ...Args>
|
template<typename ...Args>
|
||||||
void emit(Args &&...args) const { p_base.emit(std::forward<Args>(args)...); }
|
void emit(Args &&...args) const { p_base.emit(std::forward<Args>(args)...); }
|
||||||
|
|
|
@ -50,12 +50,12 @@ inline SDL_RWops *stream_to_rwops(Stream &s) {
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
rwr->read = [](SDL_RWops *rw, void *buf, Size size, Size nb) -> Size {
|
rwr->read = [](SDL_RWops *rw, void *buf, size_t size, size_t nb) -> size_t {
|
||||||
Stream *is = static_cast<Stream *>(rw->hidden.unknown.data1);
|
Stream *is = static_cast<Stream *>(rw->hidden.unknown.data1);
|
||||||
return is->read_bytes(buf, size * nb) / size;
|
return is->read_bytes(buf, size * nb) / size;
|
||||||
};
|
};
|
||||||
|
|
||||||
rwr->write = [](SDL_RWops *rw, const void *buf, Size size, Size nb) -> Size {
|
rwr->write = [](SDL_RWops *rw, const void *buf, size_t size, size_t nb) -> size_t {
|
||||||
Stream *is = static_cast<Stream *>(rw->hidden.unknown.data1);
|
Stream *is = static_cast<Stream *>(rw->hidden.unknown.data1);
|
||||||
return is->write_bytes(buf, size * nb) / size;
|
return is->write_bytes(buf, size * nb) / size;
|
||||||
};
|
};
|
||||||
|
|
|
@ -215,7 +215,7 @@ private:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Size p_slash = std::string::npos, p_dot = std::string::npos;
|
size_t p_slash = std::string::npos, p_dot = std::string::npos;
|
||||||
FileType p_type = FileType::unknown;
|
FileType p_type = FileType::unknown;
|
||||||
std::string p_path;
|
std::string p_path;
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ inline void swap(DirectoryStream &a, DirectoryStream &b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DirectoryRange: InputRange<
|
struct DirectoryRange: InputRange<
|
||||||
DirectoryRange, InputRangeTag, FileInfo, FileInfo, Size, long
|
DirectoryRange, InputRangeTag, FileInfo, FileInfo, size_t, long
|
||||||
> {
|
> {
|
||||||
DirectoryRange() = delete;
|
DirectoryRange() = delete;
|
||||||
DirectoryRange(DirectoryStream &s): p_stream(&s) {}
|
DirectoryRange(DirectoryStream &s): p_stream(&s) {}
|
||||||
|
@ -567,7 +567,7 @@ inline DirectoryRange DirectoryStream::iter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<Size I>
|
template<size_t I>
|
||||||
struct PathJoin {
|
struct PathJoin {
|
||||||
template<typename T, typename ...A>
|
template<typename T, typename ...A>
|
||||||
static void join(std::string &s, T const &a, A const &...b) {
|
static void join(std::string &s, T const &a, A const &...b) {
|
||||||
|
|
148
ostd/format.hh
148
ostd/format.hh
|
@ -43,8 +43,8 @@ namespace detail {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Size read_digits(ConstCharRange &fmt, char *buf) {
|
inline size_t read_digits(ConstCharRange &fmt, char *buf) {
|
||||||
Size ret = 0;
|
size_t ret = 0;
|
||||||
for (; !fmt.empty() && isdigit(fmt.front()); ++ret) {
|
for (; !fmt.empty() && isdigit(fmt.front()); ++ret) {
|
||||||
*buf++ = fmt.front();
|
*buf++ = fmt.front();
|
||||||
fmt.pop_front();
|
fmt.pop_front();
|
||||||
|
@ -127,7 +127,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool get_arg_param(Size idx, int ¶m, T const &val) {
|
bool get_arg_param(size_t idx, int ¶m, T const &val) {
|
||||||
if (idx) {
|
if (idx) {
|
||||||
assert(false && "not enough format args");
|
assert(false && "not enough format args");
|
||||||
return false;
|
return false;
|
||||||
|
@ -135,7 +135,7 @@ namespace detail {
|
||||||
return convert_arg_param(val, param);
|
return convert_arg_param(val, param);
|
||||||
}
|
}
|
||||||
template<typename T, typename ...A>
|
template<typename T, typename ...A>
|
||||||
bool get_arg_param(Size idx, int ¶m, T const &val, A const &...args) {
|
bool get_arg_param(size_t idx, int ¶m, T const &val, A const &...args) {
|
||||||
if (idx) {
|
if (idx) {
|
||||||
return get_arg_param(idx - 1, param, args...);
|
return get_arg_param(idx - 1, param, args...);
|
||||||
}
|
}
|
||||||
|
@ -150,8 +150,8 @@ struct FormatSpec {
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename R>
|
template<typename R>
|
||||||
bool read_until_spec(R &writer, Size *wret) {
|
bool read_until_spec(R &writer, size_t *wret) {
|
||||||
Size written = 0;
|
size_t written = 0;
|
||||||
if (wret) {
|
if (wret) {
|
||||||
*wret = 0;
|
*wret = 0;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ struct FormatSpec {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R>
|
template<typename R>
|
||||||
Size write_spaces(R &writer, Size n, bool left, char c = ' ') const {
|
size_t write_spaces(R &writer, size_t n, bool left, char c = ' ') const {
|
||||||
if (left == bool(p_flags & FMT_FLAG_DASH)) {
|
if (left == bool(p_flags & FMT_FLAG_DASH)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -199,8 +199,8 @@ struct FormatSpec {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R>
|
template<typename R>
|
||||||
Size build_spec(R &&out, ConstCharRange spec) {
|
size_t build_spec(R &&out, ConstCharRange spec) {
|
||||||
Size ret = out.put('%');
|
size_t ret = out.put('%');
|
||||||
if (p_flags & FMT_FLAG_DASH ) {
|
if (p_flags & FMT_FLAG_DASH ) {
|
||||||
ret += out.put('-');
|
ret += out.put('-');
|
||||||
}
|
}
|
||||||
|
@ -231,12 +231,12 @@ struct FormatSpec {
|
||||||
bool arg_precision() const { return p_arg_precision; }
|
bool arg_precision() const { return p_arg_precision; }
|
||||||
|
|
||||||
template<typename ...A>
|
template<typename ...A>
|
||||||
bool set_width(Size idx, A const &...args) {
|
bool set_width(size_t idx, A const &...args) {
|
||||||
return detail::get_arg_param(idx, p_width, args...);
|
return detail::get_arg_param(idx, p_width, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ...A>
|
template<typename ...A>
|
||||||
bool set_precision(Size idx, A const &...args) {
|
bool set_precision(size_t idx, A const &...args) {
|
||||||
return detail::get_arg_param(idx, p_precision, args...);
|
return detail::get_arg_param(idx, p_precision, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read_spec() {
|
bool read_spec() {
|
||||||
Size ndig = detail::read_digits(p_fmt, p_buf);
|
size_t ndig = detail::read_digits(p_fmt, p_buf);
|
||||||
|
|
||||||
bool havepos = false;
|
bool havepos = false;
|
||||||
p_index = 0;
|
p_index = 0;
|
||||||
|
@ -364,11 +364,11 @@ protected:
|
||||||
|
|
||||||
/* parse flags */
|
/* parse flags */
|
||||||
p_flags = 0;
|
p_flags = 0;
|
||||||
Size skipd = 0;
|
size_t skipd = 0;
|
||||||
if (havepos || !ndig) {
|
if (havepos || !ndig) {
|
||||||
p_flags = detail::parse_fmt_flags(p_fmt, 0);
|
p_flags = detail::parse_fmt_flags(p_fmt, 0);
|
||||||
} else {
|
} else {
|
||||||
for (Size i = 0; i < ndig; ++i) {
|
for (size_t i = 0; i < ndig; ++i) {
|
||||||
if (p_buf[i] != '0') {
|
if (p_buf[i] != '0') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -449,10 +449,10 @@ inline bool to_format(T const &v, R &writer, FormatSpec const &fs) {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
inline Ptrdiff write_u(R &writer, FormatSpec const *fl, bool neg, T val) {
|
inline ptrdiff_t write_u(R &writer, FormatSpec const *fl, bool neg, T val) {
|
||||||
char buf[20];
|
char buf[20];
|
||||||
Ptrdiff r = 0;
|
ptrdiff_t r = 0;
|
||||||
Size n = 0;
|
size_t n = 0;
|
||||||
|
|
||||||
char spec = fl->spec();
|
char spec = fl->spec();
|
||||||
if (spec == 's') spec = 'd';
|
if (spec == 's') spec = 'd';
|
||||||
|
@ -505,16 +505,16 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R, typename ...A>
|
template<typename R, typename ...A>
|
||||||
static Ptrdiff format_impl(
|
static ptrdiff_t format_impl(
|
||||||
R &writer, Size &fmtn, bool escape,
|
R &writer, size_t &fmtn, bool escape,
|
||||||
ConstCharRange fmt, A const &...args
|
ConstCharRange fmt, A const &...args
|
||||||
);
|
);
|
||||||
|
|
||||||
template<Size I>
|
template<size_t I>
|
||||||
struct FmtTupleUnpacker {
|
struct FmtTupleUnpacker {
|
||||||
template<typename R, typename T, typename ...A>
|
template<typename R, typename T, typename ...A>
|
||||||
static inline Ptrdiff unpack(
|
static inline ptrdiff_t unpack(
|
||||||
R &writer, Size &fmtn, bool esc, ConstCharRange fmt,
|
R &writer, size_t &fmtn, bool esc, ConstCharRange fmt,
|
||||||
T const &item, A const &...args
|
T const &item, A const &...args
|
||||||
) {
|
) {
|
||||||
return FmtTupleUnpacker<I - 1>::unpack(
|
return FmtTupleUnpacker<I - 1>::unpack(
|
||||||
|
@ -526,8 +526,8 @@ namespace detail {
|
||||||
template<>
|
template<>
|
||||||
struct FmtTupleUnpacker<0> {
|
struct FmtTupleUnpacker<0> {
|
||||||
template<typename R, typename T, typename ...A>
|
template<typename R, typename T, typename ...A>
|
||||||
static inline Ptrdiff unpack(
|
static inline ptrdiff_t unpack(
|
||||||
R &writer, Size &fmtn, bool esc, ConstCharRange fmt,
|
R &writer, size_t &fmtn, bool esc, ConstCharRange fmt,
|
||||||
T const &, A const &...args
|
T const &, A const &...args
|
||||||
) {
|
) {
|
||||||
return format_impl(writer, fmtn, esc, fmt, args...);
|
return format_impl(writer, fmtn, esc, fmt, args...);
|
||||||
|
@ -547,16 +547,16 @@ namespace detail {
|
||||||
constexpr bool is_tuple_like = decltype(tuple_like_test<T>(0))::value;
|
constexpr bool is_tuple_like = decltype(tuple_like_test<T>(0))::value;
|
||||||
|
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
inline Ptrdiff format_ritem(
|
inline ptrdiff_t format_ritem(
|
||||||
R &writer, Size &fmtn, bool esc, bool, ConstCharRange fmt,
|
R &writer, size_t &fmtn, bool esc, bool, ConstCharRange fmt,
|
||||||
T const &item, EnableIf<!is_tuple_like<T>, bool> = true
|
T const &item, EnableIf<!is_tuple_like<T>, bool> = true
|
||||||
) {
|
) {
|
||||||
return format_impl(writer, fmtn, esc, fmt, item);
|
return format_impl(writer, fmtn, esc, fmt, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
inline Ptrdiff format_ritem(
|
inline ptrdiff_t format_ritem(
|
||||||
R &writer, Size &fmtn, bool esc, bool expandval, ConstCharRange fmt,
|
R &writer, size_t &fmtn, bool esc, bool expandval, ConstCharRange fmt,
|
||||||
T const &item, EnableIf<is_tuple_like<T>, bool> = true
|
T const &item, EnableIf<is_tuple_like<T>, bool> = true
|
||||||
) {
|
) {
|
||||||
if (expandval) {
|
if (expandval) {
|
||||||
|
@ -568,7 +568,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
inline Ptrdiff write_range(
|
inline ptrdiff_t write_range(
|
||||||
R &writer, FormatSpec const *fl, bool escape, bool expandval,
|
R &writer, FormatSpec const *fl, bool escape, bool expandval,
|
||||||
ConstCharRange sep, T const &val, EnableIf<detail::IterableTest<T>, bool> = true
|
ConstCharRange sep, T const &val, EnableIf<detail::IterableTest<T>, bool> = true
|
||||||
) {
|
) {
|
||||||
|
@ -576,10 +576,10 @@ namespace detail {
|
||||||
if (range.empty()) {
|
if (range.empty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Ptrdiff ret = 0;
|
ptrdiff_t ret = 0;
|
||||||
Size fmtn = 0;
|
size_t fmtn = 0;
|
||||||
/* test first item */
|
/* test first item */
|
||||||
Ptrdiff fret = format_ritem(
|
ptrdiff_t fret = format_ritem(
|
||||||
writer, fmtn, escape, expandval, fl->rest(), range.front()
|
writer, fmtn, escape, expandval, fl->rest(), range.front()
|
||||||
);
|
);
|
||||||
if (fret < 0) {
|
if (fret < 0) {
|
||||||
|
@ -606,7 +606,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
inline Ptrdiff write_range(
|
inline ptrdiff_t write_range(
|
||||||
R &, FormatSpec const *, bool, bool, ConstCharRange,
|
R &, FormatSpec const *, bool, bool, ConstCharRange,
|
||||||
T const &, EnableIf<!detail::IterableTest<T>, bool> = true
|
T const &, EnableIf<!detail::IterableTest<T>, bool> = true
|
||||||
) {
|
) {
|
||||||
|
@ -637,7 +637,7 @@ namespace detail {
|
||||||
|
|
||||||
inline char const *escape_fmt_char(char v, char quote) {
|
inline char const *escape_fmt_char(char v, char quote) {
|
||||||
if ((v >= 0 && v < 0x20) || (v == quote)) {
|
if ((v >= 0 && v < 0x20) || (v == quote)) {
|
||||||
return fmt_escapes[Size(v)];
|
return fmt_escapes[size_t(v)];
|
||||||
} else if (v == 0x7F) {
|
} else if (v == 0x7F) {
|
||||||
return "\\x7F";
|
return "\\x7F";
|
||||||
}
|
}
|
||||||
|
@ -678,15 +678,15 @@ namespace detail {
|
||||||
|
|
||||||
/* string base writer */
|
/* string base writer */
|
||||||
template<typename R>
|
template<typename R>
|
||||||
Ptrdiff write_str(R &writer, bool escape, ConstCharRange val) {
|
ptrdiff_t write_str(R &writer, bool escape, ConstCharRange val) {
|
||||||
if (escape) {
|
if (escape) {
|
||||||
return write_str(writer, false, escape_fmt_str(val));
|
return write_str(writer, false, escape_fmt_str(val));
|
||||||
}
|
}
|
||||||
Size n = val.size();
|
size_t n = val.size();
|
||||||
if (this->precision()) {
|
if (this->precision()) {
|
||||||
n = this->precision();
|
n = this->precision();
|
||||||
}
|
}
|
||||||
Ptrdiff r = n;
|
ptrdiff_t r = n;
|
||||||
r += this->write_spaces(writer, n, true);
|
r += this->write_spaces(writer, n, true);
|
||||||
writer.put_n(&val[0], n);
|
writer.put_n(&val[0], n);
|
||||||
r += this->write_spaces(writer, n, false);
|
r += this->write_spaces(writer, n, false);
|
||||||
|
@ -695,7 +695,7 @@ namespace detail {
|
||||||
|
|
||||||
/* any string value */
|
/* any string value */
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
Ptrdiff write(
|
ptrdiff_t write(
|
||||||
R &writer, bool escape, T const &val, EnableIf<
|
R &writer, bool escape, T const &val, EnableIf<
|
||||||
IsConstructible<ConstCharRange, T const &>, bool
|
IsConstructible<ConstCharRange, T const &>, bool
|
||||||
> = true
|
> = true
|
||||||
|
@ -709,7 +709,7 @@ namespace detail {
|
||||||
|
|
||||||
/* character */
|
/* character */
|
||||||
template<typename R>
|
template<typename R>
|
||||||
Ptrdiff write(R &writer, bool escape, char val) {
|
ptrdiff_t write(R &writer, bool escape, char val) {
|
||||||
if (this->spec() != 's' && this->spec() != 'c') {
|
if (this->spec() != 's' && this->spec() != 'c') {
|
||||||
assert(false && "cannot print chars with the given spec");
|
assert(false && "cannot print chars with the given spec");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -719,7 +719,7 @@ namespace detail {
|
||||||
if (esc) {
|
if (esc) {
|
||||||
char buf[6];
|
char buf[6];
|
||||||
buf[0] = '\'';
|
buf[0] = '\'';
|
||||||
Size elen = strlen(esc);
|
size_t elen = strlen(esc);
|
||||||
memcpy(buf + 1, esc, elen);
|
memcpy(buf + 1, esc, elen);
|
||||||
buf[elen + 1] = '\'';
|
buf[elen + 1] = '\'';
|
||||||
/* invoke proper overload via ptr */
|
/* invoke proper overload via ptr */
|
||||||
|
@ -727,7 +727,7 @@ namespace detail {
|
||||||
return write(writer, false, bufp, elen + 2);
|
return write(writer, false, bufp, elen + 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ptrdiff r = 1 + escape * 2;
|
ptrdiff_t r = 1 + escape * 2;
|
||||||
r += this->write_spaces(writer, 1 + escape * 2, true);
|
r += this->write_spaces(writer, 1 + escape * 2, true);
|
||||||
if (escape) {
|
if (escape) {
|
||||||
writer.put('\'');
|
writer.put('\'');
|
||||||
|
@ -742,7 +742,7 @@ namespace detail {
|
||||||
|
|
||||||
/* bool */
|
/* bool */
|
||||||
template<typename R>
|
template<typename R>
|
||||||
Ptrdiff write(R &writer, bool, bool val) {
|
ptrdiff_t write(R &writer, bool, bool val) {
|
||||||
if (this->spec() == 's') {
|
if (this->spec() == 's') {
|
||||||
return write(writer, ("false\0true") + (6 * val));
|
return write(writer, ("false\0true") + (6 * val));
|
||||||
} else {
|
} else {
|
||||||
|
@ -752,7 +752,7 @@ namespace detail {
|
||||||
|
|
||||||
/* signed integers */
|
/* signed integers */
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
Ptrdiff write(
|
ptrdiff_t write(
|
||||||
R &writer, bool, T val, EnableIf<
|
R &writer, bool, T val, EnableIf<
|
||||||
IsIntegral<T> && IsSigned<T>, bool
|
IsIntegral<T> && IsSigned<T>, bool
|
||||||
> = true
|
> = true
|
||||||
|
@ -766,7 +766,7 @@ namespace detail {
|
||||||
|
|
||||||
/* unsigned integers */
|
/* unsigned integers */
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
Ptrdiff write(
|
ptrdiff_t write(
|
||||||
R &writer, bool, T val, EnableIf<
|
R &writer, bool, T val, EnableIf<
|
||||||
IsIntegral<T> && IsUnsigned<T>, bool
|
IsIntegral<T> && IsUnsigned<T>, bool
|
||||||
> = true
|
> = true
|
||||||
|
@ -775,7 +775,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R, typename T, bool Long = IsSame<T, ldouble>>
|
template<typename R, typename T, bool Long = IsSame<T, ldouble>>
|
||||||
Ptrdiff write(
|
ptrdiff_t write(
|
||||||
R &writer, bool, T val, EnableIf<IsFloatingPoint<T>, bool> = true
|
R &writer, bool, T val, EnableIf<IsFloatingPoint<T>, bool> = true
|
||||||
) {
|
) {
|
||||||
char buf[16], rbuf[128];
|
char buf[16], rbuf[128];
|
||||||
|
@ -795,13 +795,13 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[this->build_spec(iter(buf), fmtspec)] = '\0';
|
buf[this->build_spec(iter(buf), fmtspec)] = '\0';
|
||||||
Ptrdiff ret = snprintf(
|
ptrdiff_t ret = snprintf(
|
||||||
rbuf, sizeof(rbuf), buf, this->width(),
|
rbuf, sizeof(rbuf), buf, this->width(),
|
||||||
this->has_precision() ? this->precision() : 6, val
|
this->has_precision() ? this->precision() : 6, val
|
||||||
);
|
);
|
||||||
|
|
||||||
char *dbuf = nullptr;
|
char *dbuf = nullptr;
|
||||||
if (Size(ret) >= sizeof(rbuf)) {
|
if (size_t(ret) >= sizeof(rbuf)) {
|
||||||
/* this should typically never happen */
|
/* this should typically never happen */
|
||||||
dbuf = new char[ret + 1];
|
dbuf = new char[ret + 1];
|
||||||
ret = snprintf(
|
ret = snprintf(
|
||||||
|
@ -818,7 +818,7 @@ namespace detail {
|
||||||
|
|
||||||
/* pointer value */
|
/* pointer value */
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
Ptrdiff write(
|
ptrdiff_t write(
|
||||||
R &writer, bool, T *val, EnableIf<
|
R &writer, bool, T *val, EnableIf<
|
||||||
!IsConstructible<ConstCharRange, T *>, bool
|
!IsConstructible<ConstCharRange, T *>, bool
|
||||||
> = true
|
> = true
|
||||||
|
@ -827,12 +827,12 @@ namespace detail {
|
||||||
this->p_spec = 'x';
|
this->p_spec = 'x';
|
||||||
this->p_flags |= FMT_FLAG_HASH;
|
this->p_flags |= FMT_FLAG_HASH;
|
||||||
}
|
}
|
||||||
return write(writer, false, Size(val));
|
return write(writer, false, size_t(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generic value */
|
/* generic value */
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
Ptrdiff write(
|
ptrdiff_t write(
|
||||||
R &writer, bool, T const &val, EnableIf<
|
R &writer, bool, T const &val, EnableIf<
|
||||||
!IsArithmetic<T> &&
|
!IsArithmetic<T> &&
|
||||||
!IsConstructible<ConstCharRange, T const &> &&
|
!IsConstructible<ConstCharRange, T const &> &&
|
||||||
|
@ -848,7 +848,7 @@ namespace detail {
|
||||||
|
|
||||||
/* custom format case */
|
/* custom format case */
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
Ptrdiff write(
|
ptrdiff_t write(
|
||||||
R &writer, bool, T const &val,
|
R &writer, bool, T const &val,
|
||||||
EnableIf<FmtTofmtTest<T, TostrRange<R>>, bool> = true
|
EnableIf<FmtTofmtTest<T, TostrRange<R>>, bool> = true
|
||||||
) {
|
) {
|
||||||
|
@ -861,7 +861,7 @@ namespace detail {
|
||||||
|
|
||||||
/* generic failure case */
|
/* generic failure case */
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
Ptrdiff write(
|
ptrdiff_t write(
|
||||||
R &, bool, T const &, EnableIf<
|
R &, bool, T const &, EnableIf<
|
||||||
!IsArithmetic<T> &&
|
!IsArithmetic<T> &&
|
||||||
!IsConstructible<ConstCharRange, T const &> &&
|
!IsConstructible<ConstCharRange, T const &> &&
|
||||||
|
@ -874,7 +874,7 @@ namespace detail {
|
||||||
|
|
||||||
/* actual writer */
|
/* actual writer */
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
Ptrdiff write_arg(R &writer, Size idx, T const &val) {
|
ptrdiff_t write_arg(R &writer, size_t idx, T const &val) {
|
||||||
if (idx) {
|
if (idx) {
|
||||||
assert(false && "not enough format args");
|
assert(false && "not enough format args");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -883,8 +883,8 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R, typename T, typename ...A>
|
template<typename R, typename T, typename ...A>
|
||||||
Ptrdiff write_arg(
|
ptrdiff_t write_arg(
|
||||||
R &writer, Size idx, T const &val, A const &...args
|
R &writer, size_t idx, T const &val, A const &...args
|
||||||
) {
|
) {
|
||||||
if (idx) {
|
if (idx) {
|
||||||
return write_arg(writer, idx - 1, args...);
|
return write_arg(writer, idx - 1, args...);
|
||||||
|
@ -894,8 +894,8 @@ namespace detail {
|
||||||
|
|
||||||
/* range writer */
|
/* range writer */
|
||||||
template<typename R, typename T>
|
template<typename R, typename T>
|
||||||
Ptrdiff write_range(
|
ptrdiff_t write_range(
|
||||||
R &writer, Size idx, bool expandval,
|
R &writer, size_t idx, bool expandval,
|
||||||
ConstCharRange sep, T const &val
|
ConstCharRange sep, T const &val
|
||||||
) {
|
) {
|
||||||
if (idx) {
|
if (idx) {
|
||||||
|
@ -908,8 +908,8 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R, typename T, typename ...A>
|
template<typename R, typename T, typename ...A>
|
||||||
Ptrdiff write_range(
|
ptrdiff_t write_range(
|
||||||
R &writer, Size idx, bool expandval, ConstCharRange sep,
|
R &writer, size_t idx, bool expandval, ConstCharRange sep,
|
||||||
T const &val, A const &...args
|
T const &val, A const &...args
|
||||||
) {
|
) {
|
||||||
if (idx) {
|
if (idx) {
|
||||||
|
@ -922,22 +922,22 @@ namespace detail {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename R, typename ...A>
|
template<typename R, typename ...A>
|
||||||
inline Ptrdiff format_impl(
|
inline ptrdiff_t format_impl(
|
||||||
R &writer, Size &fmtn, bool escape, ConstCharRange fmt, A const &...args
|
R &writer, size_t &fmtn, bool escape, ConstCharRange fmt, A const &...args
|
||||||
) {
|
) {
|
||||||
Size argidx = 1, retn = 0, twr = 0;
|
size_t argidx = 1, retn = 0, twr = 0;
|
||||||
Ptrdiff written = 0;
|
ptrdiff_t written = 0;
|
||||||
detail::WriteSpec spec(fmt, escape);
|
detail::WriteSpec spec(fmt, escape);
|
||||||
while (spec.read_until_spec(writer, &twr)) {
|
while (spec.read_until_spec(writer, &twr)) {
|
||||||
written += twr;
|
written += twr;
|
||||||
Size argpos = spec.index();
|
size_t argpos = spec.index();
|
||||||
if (spec.is_nested()) {
|
if (spec.is_nested()) {
|
||||||
if (!argpos) {
|
if (!argpos) {
|
||||||
argpos = argidx++;
|
argpos = argidx++;
|
||||||
}
|
}
|
||||||
/* FIXME: figure out a better way */
|
/* FIXME: figure out a better way */
|
||||||
detail::WriteSpec nspec(spec.nested(), spec.nested_escape());
|
detail::WriteSpec nspec(spec.nested(), spec.nested_escape());
|
||||||
Ptrdiff sw = nspec.write_range(
|
ptrdiff_t sw = nspec.write_range(
|
||||||
writer, argpos - 1, (spec.flags() & FMT_FLAG_HASH),
|
writer, argpos - 1, (spec.flags() & FMT_FLAG_HASH),
|
||||||
spec.nested_sep(), args...
|
spec.nested_sep(), args...
|
||||||
);
|
);
|
||||||
|
@ -973,7 +973,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (spec.arg_width()) {
|
if (spec.arg_width()) {
|
||||||
if (argpos <= (Size(argprec) + 1)) {
|
if (argpos <= (size_t(argprec) + 1)) {
|
||||||
assert(false && "argument width not given");
|
assert(false && "argument width not given");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -982,7 +982,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ptrdiff sw = spec.write_arg(writer, argpos - 1, args...);
|
ptrdiff_t sw = spec.write_arg(writer, argpos - 1, args...);
|
||||||
if (sw < 0) {
|
if (sw < 0) {
|
||||||
return sw;
|
return sw;
|
||||||
}
|
}
|
||||||
|
@ -994,10 +994,10 @@ namespace detail {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R, typename ...A>
|
template<typename R, typename ...A>
|
||||||
inline Ptrdiff format_impl(
|
inline ptrdiff_t format_impl(
|
||||||
R &writer, Size &fmtn, bool, ConstCharRange fmt
|
R &writer, size_t &fmtn, bool, ConstCharRange fmt
|
||||||
) {
|
) {
|
||||||
Size written = 0;
|
size_t written = 0;
|
||||||
detail::WriteSpec spec(fmt, false);
|
detail::WriteSpec spec(fmt, false);
|
||||||
if (spec.read_until_spec(writer, &written)) {
|
if (spec.read_until_spec(writer, &written)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1008,15 +1008,15 @@ namespace detail {
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
template<typename R, typename ...A>
|
template<typename R, typename ...A>
|
||||||
inline Ptrdiff format(
|
inline ptrdiff_t format(
|
||||||
R &&writer, Size &fmtn, ConstCharRange fmt, A const &...args
|
R &&writer, size_t &fmtn, ConstCharRange fmt, A const &...args
|
||||||
) {
|
) {
|
||||||
return detail::format_impl(writer, fmtn, false, fmt, args...);
|
return detail::format_impl(writer, fmtn, false, fmt, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R, typename ...A>
|
template<typename R, typename ...A>
|
||||||
Ptrdiff format(R &&writer, ConstCharRange fmt, A const &...args) {
|
ptrdiff_t format(R &&writer, ConstCharRange fmt, A const &...args) {
|
||||||
Size fmtn = 0;
|
size_t fmtn = 0;
|
||||||
return format(writer, fmtn, fmt, args...);
|
return format(writer, fmtn, fmt, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ BinaryNegate<T> not2(T const &fn) {
|
||||||
|
|
||||||
/* endian swap */
|
/* endian swap */
|
||||||
|
|
||||||
template<typename T, Size N = sizeof(T), bool IsNum = IsArithmetic<T>>
|
template<typename T, size_t N = sizeof(T), bool IsNum = IsArithmetic<T>>
|
||||||
struct EndianSwap;
|
struct EndianSwap;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -182,7 +182,7 @@ template<typename T>
|
||||||
T endian_swap(T x) { return EndianSwap<T>()(x); }
|
T endian_swap(T x) { return EndianSwap<T>()(x); }
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T, Size N = sizeof(T), bool IsNum = IsArithmetic<T>>
|
template<typename T, size_t N = sizeof(T), bool IsNum = IsArithmetic<T>>
|
||||||
struct EndianSame;
|
struct EndianSame;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -26,14 +26,14 @@ namespace detail {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename R>
|
template<typename R>
|
||||||
static inline Size estimate_hrsize(
|
static inline size_t estimate_hrsize(
|
||||||
const R &range, EnableIf<IsFiniteRandomAccessRange<R>, bool> = true
|
const R &range, EnableIf<IsFiniteRandomAccessRange<R>, bool> = true
|
||||||
) {
|
) {
|
||||||
return range.size();
|
return range.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R>
|
template<typename R>
|
||||||
static inline Size estimate_hrsize(
|
static inline size_t estimate_hrsize(
|
||||||
const R &, EnableIf<!IsFiniteRandomAccessRange<R>, bool> = true
|
const R &, EnableIf<!IsFiniteRandomAccessRange<R>, bool> = true
|
||||||
) {
|
) {
|
||||||
/* we have no idea how big the range actually is */
|
/* we have no idea how big the range actually is */
|
||||||
|
@ -139,49 +139,49 @@ namespace detail {
|
||||||
* If this is not possible, use the upper bound and pad the
|
* If this is not possible, use the upper bound and pad the
|
||||||
* structure with some extra bytes.
|
* structure with some extra bytes.
|
||||||
*/
|
*/
|
||||||
static constexpr Size CacheLineSize = 64;
|
static constexpr size_t CacheLineSize = 64;
|
||||||
static constexpr Size ChunkLowerBound = 32;
|
static constexpr size_t ChunkLowerBound = 32;
|
||||||
static constexpr Size ChunkUpperBound = 128;
|
static constexpr size_t ChunkUpperBound = 128;
|
||||||
|
|
||||||
template<typename E, Size N> constexpr Size HashChainAlign =
|
template<typename E, size_t N> constexpr size_t HashChainAlign =
|
||||||
(((sizeof(HashChain<E>[N]) + sizeof(void *)) % CacheLineSize) == 0)
|
(((sizeof(HashChain<E>[N]) + sizeof(void *)) % CacheLineSize) == 0)
|
||||||
? N : HashChainAlign<E, N + 1>;
|
? N : HashChainAlign<E, N + 1>;
|
||||||
|
|
||||||
template<typename E>
|
template<typename E>
|
||||||
constexpr Size HashChainAlign<E, ChunkUpperBound> = ChunkUpperBound;
|
constexpr size_t HashChainAlign<E, ChunkUpperBound> = ChunkUpperBound;
|
||||||
|
|
||||||
template<Size N, bool B>
|
template<size_t N, bool B>
|
||||||
struct HashChainPad;
|
struct HashChainPad;
|
||||||
|
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct HashChainPad<N, true> {};
|
struct HashChainPad<N, true> {};
|
||||||
|
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct HashChainPad<N, false> {
|
struct HashChainPad<N, false> {
|
||||||
byte pad[CacheLineSize - (N % CacheLineSize)];
|
byte pad[CacheLineSize - (N % CacheLineSize)];
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct HashPad: HashChainPad<N, N % CacheLineSize == 0> {};
|
struct HashPad: HashChainPad<N, N % CacheLineSize == 0> {};
|
||||||
|
|
||||||
template<
|
template<
|
||||||
typename E, Size V = HashChainAlign<E, ChunkLowerBound>,
|
typename E, size_t V = HashChainAlign<E, ChunkLowerBound>,
|
||||||
bool P = (V == ChunkUpperBound)
|
bool P = (V == ChunkUpperBound)
|
||||||
>
|
>
|
||||||
struct HashChunk;
|
struct HashChunk;
|
||||||
|
|
||||||
template<typename E, Size V>
|
template<typename E, size_t V>
|
||||||
struct HashChunk<E, V, false> {
|
struct HashChunk<E, V, false> {
|
||||||
static constexpr Size num = V;
|
static constexpr size_t num = V;
|
||||||
HashChain<E> chains[num];
|
HashChain<E> chains[num];
|
||||||
HashChunk *next;
|
HashChunk *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename E, Size V>
|
template<typename E, size_t V>
|
||||||
struct HashChunk<E, V, true>: HashPad<
|
struct HashChunk<E, V, true>: HashPad<
|
||||||
sizeof(HashChain<E>[V]) + sizeof(void *)
|
sizeof(HashChain<E>[V]) + sizeof(void *)
|
||||||
> {
|
> {
|
||||||
static constexpr Size num = V;
|
static constexpr size_t num = V;
|
||||||
HashChain<E> chains[num];
|
HashChain<E> chains[num];
|
||||||
HashChunk *next;
|
HashChunk *next;
|
||||||
};
|
};
|
||||||
|
@ -201,8 +201,8 @@ private:
|
||||||
using Chain = HashChain<E>;
|
using Chain = HashChain<E>;
|
||||||
using Chunk = HashChunk<E>;
|
using Chunk = HashChunk<E>;
|
||||||
|
|
||||||
Size p_size;
|
size_t p_size;
|
||||||
Size p_len;
|
size_t p_len;
|
||||||
|
|
||||||
Chunk *p_chunks;
|
Chunk *p_chunks;
|
||||||
Chain *p_unused;
|
Chain *p_unused;
|
||||||
|
@ -234,7 +234,7 @@ private:
|
||||||
clear_buckets();
|
clear_buckets();
|
||||||
}
|
}
|
||||||
|
|
||||||
Chain *find(const K &key, Size &h) const {
|
Chain *find(const K &key, size_t &h) const {
|
||||||
if (!p_size) {
|
if (!p_size) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ private:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chain *insert_node(Size h, Chain *c) {
|
Chain *insert_node(size_t h, Chain *c) {
|
||||||
Chain **cp = p_data.first();
|
Chain **cp = p_data.first();
|
||||||
Chain *it = cp[h + 1];
|
Chain *it = cp[h + 1];
|
||||||
c->next = it;
|
c->next = it;
|
||||||
|
@ -287,7 +287,7 @@ private:
|
||||||
allocator_construct(get_challoc(), chunk);
|
allocator_construct(get_challoc(), chunk);
|
||||||
chunk->next = p_chunks;
|
chunk->next = p_chunks;
|
||||||
p_chunks = chunk;
|
p_chunks = chunk;
|
||||||
for (Size i = 0; i < (Chunk::num - 1); ++i) {
|
for (size_t i = 0; i < (Chunk::num - 1); ++i) {
|
||||||
chunk->chains[i].next = &chunk->chains[i + 1];
|
chunk->chains[i].next = &chunk->chains[i + 1];
|
||||||
}
|
}
|
||||||
chunk->chains[Chunk::num - 1].next = p_unused;
|
chunk->chains[Chunk::num - 1].next = p_unused;
|
||||||
|
@ -299,7 +299,7 @@ private:
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chain *insert(Size h) {
|
Chain *insert(size_t h) {
|
||||||
return insert_node(h, request_node());
|
return insert_node(h, request_node());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,24 +311,24 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rehash_ahead(Size n) {
|
void rehash_ahead(size_t n) {
|
||||||
if (!bucket_count()) {
|
if (!bucket_count()) {
|
||||||
reserve(n);
|
reserve(n);
|
||||||
} else if ((float(size() + n) / bucket_count()) > max_load_factor()) {
|
} else if ((float(size() + n) / bucket_count()) > max_load_factor()) {
|
||||||
rehash(Size((size() + 1) / max_load_factor()) * 2);
|
rehash(size_t((size() + 1) / max_load_factor()) * 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template<typename U>
|
template<typename U>
|
||||||
T &insert(Size h, U &&key) {
|
T &insert(size_t h, U &&key) {
|
||||||
Chain *c = insert(h);
|
Chain *c = insert(h);
|
||||||
B::set_key(c->value, std::forward<U>(key), get_alloc());
|
B::set_key(c->value, std::forward<U>(key), get_alloc());
|
||||||
return B::get_data(c->value);
|
return B::get_data(c->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
T &access_or_insert(const K &key) {
|
T &access_or_insert(const K &key) {
|
||||||
Size h = 0;
|
size_t h = 0;
|
||||||
Chain *c = find(key, h);
|
Chain *c = find(key, h);
|
||||||
if (c) {
|
if (c) {
|
||||||
return B::get_data(c->value);
|
return B::get_data(c->value);
|
||||||
|
@ -338,7 +338,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
T &access_or_insert(K &&key) {
|
T &access_or_insert(K &&key) {
|
||||||
Size h = 0;
|
size_t h = 0;
|
||||||
Chain *c = find(key, h);
|
Chain *c = find(key, h);
|
||||||
if (c) {
|
if (c) {
|
||||||
return B::get_data(c->value);
|
return B::get_data(c->value);
|
||||||
|
@ -348,7 +348,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
T *access(const K &key) const {
|
T *access(const K &key) const {
|
||||||
Size h;
|
size_t h;
|
||||||
Chain *c = find(key, h);
|
Chain *c = find(key, h);
|
||||||
if (c) {
|
if (c) {
|
||||||
return &B::get_data(c->value);
|
return &B::get_data(c->value);
|
||||||
|
@ -391,7 +391,7 @@ protected:
|
||||||
return p_data.second().first().second().second();
|
return p_data.second().first().second().second();
|
||||||
}
|
}
|
||||||
|
|
||||||
Hashtable(Size size, const H &hf, const C &eqf, const A &alloc):
|
Hashtable(size_t size, const H &hf, const C &eqf, const A &alloc):
|
||||||
p_size(size), p_len(0), p_chunks(nullptr), p_unused(nullptr),
|
p_size(size), p_len(0), p_chunks(nullptr), p_unused(nullptr),
|
||||||
p_data(nullptr, FAPair(AllocPair(alloc, CoreAllocPair(alloc, alloc)),
|
p_data(nullptr, FAPair(AllocPair(alloc, CoreAllocPair(alloc, alloc)),
|
||||||
FuncPair(hf, eqf))),
|
FuncPair(hf, eqf))),
|
||||||
|
@ -413,7 +413,7 @@ protected:
|
||||||
init_buckets();
|
init_buckets();
|
||||||
Chain **och = ht.p_data.first();
|
Chain **och = ht.p_data.first();
|
||||||
for (Chain *oc = *och; oc; oc = oc->next) {
|
for (Chain *oc = *och; oc; oc = oc->next) {
|
||||||
Size h = bucket(B::get_key(oc->value));
|
size_t h = bucket(B::get_key(oc->value));
|
||||||
Chain *nc = insert(h);
|
Chain *nc = insert(h);
|
||||||
allocator_destroy(get_alloc(), &nc->value);
|
allocator_destroy(get_alloc(), &nc->value);
|
||||||
allocator_construct(get_alloc(), &nc->value, oc->value);
|
allocator_construct(get_alloc(), &nc->value, oc->value);
|
||||||
|
@ -451,7 +451,7 @@ protected:
|
||||||
init_buckets();
|
init_buckets();
|
||||||
Chain **och = ht.p_data.first();
|
Chain **och = ht.p_data.first();
|
||||||
for (Chain *oc = *och; oc; oc = oc->next) {
|
for (Chain *oc = *och; oc; oc = oc->next) {
|
||||||
Size h = bucket(B::get_key(oc->value));
|
size_t h = bucket(B::get_key(oc->value));
|
||||||
Chain *nc = insert(h);
|
Chain *nc = insert(h);
|
||||||
B::swap_elem(oc->value, nc->value);
|
B::swap_elem(oc->value, nc->value);
|
||||||
}
|
}
|
||||||
|
@ -495,11 +495,11 @@ protected:
|
||||||
if (load_factor() <= max_load_factor()) {
|
if (load_factor() <= max_load_factor()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rehash(Size(size() / max_load_factor()) * 2);
|
rehash(size_t(size() / max_load_factor()) * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reserve_at_least(Size count) {
|
void reserve_at_least(size_t count) {
|
||||||
Size nc = Size(ceil(count / max_load_factor()));
|
size_t nc = size_t(ceil(count / max_load_factor()));
|
||||||
if (p_size > nc) {
|
if (p_size > nc) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -542,18 +542,18 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() const { return p_len == 0; }
|
bool empty() const { return p_len == 0; }
|
||||||
Size size() const { return p_len; }
|
size_t size() const { return p_len; }
|
||||||
Size max_size() const { return Size(~0) / sizeof(E); }
|
size_t max_size() const { return size_t(~0) / sizeof(E); }
|
||||||
|
|
||||||
Size bucket_count() const { return p_size; }
|
size_t bucket_count() const { return p_size; }
|
||||||
Size max_bucket_count() const { return Size(~0) / sizeof(Chain); }
|
size_t max_bucket_count() const { return size_t(~0) / sizeof(Chain); }
|
||||||
|
|
||||||
Size bucket(const K &key) const {
|
size_t bucket(const K &key) const {
|
||||||
return get_hash()(key) & (p_size - 1);
|
return get_hash()(key) & (p_size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Size bucket_size(Size n) const {
|
size_t bucket_size(size_t n) const {
|
||||||
Size ret = 0;
|
size_t ret = 0;
|
||||||
if (n >= p_size) {
|
if (n >= p_size) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -573,12 +573,12 @@ public:
|
||||||
* gotta make sure that equal keys always come after
|
* gotta make sure that equal keys always come after
|
||||||
* each other (this is then used by other APIs)
|
* each other (this is then used by other APIs)
|
||||||
*/
|
*/
|
||||||
Size h = bucket(B::get_key(elem));
|
size_t h = bucket(B::get_key(elem));
|
||||||
Chain *ch = insert(h);
|
Chain *ch = insert(h);
|
||||||
B::swap_elem(ch->value, elem);
|
B::swap_elem(ch->value, elem);
|
||||||
return std::make_pair(Range(ch), true);
|
return std::make_pair(Range(ch), true);
|
||||||
}
|
}
|
||||||
Size h = bucket(B::get_key(elem));
|
size_t h = bucket(B::get_key(elem));
|
||||||
Chain *found = nullptr;
|
Chain *found = nullptr;
|
||||||
bool ins = true;
|
bool ins = true;
|
||||||
Chain **cp = p_data.first();
|
Chain **cp = p_data.first();
|
||||||
|
@ -596,20 +596,20 @@ public:
|
||||||
return std::make_pair(Range(found), ins);
|
return std::make_pair(Range(found), ins);
|
||||||
}
|
}
|
||||||
|
|
||||||
Size erase(const K &key) {
|
size_t erase(const K &key) {
|
||||||
Size h = 0;
|
size_t h = 0;
|
||||||
Chain *c = find(key, h);
|
Chain *c = find(key, h);
|
||||||
if (!c) {
|
if (!c) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Chain **cp = p_data.first();
|
Chain **cp = p_data.first();
|
||||||
Size olen = p_len;
|
size_t olen = p_len;
|
||||||
for (Chain *e = cp[h + 1]; c != e; c = c->next) {
|
for (Chain *e = cp[h + 1]; c != e; c = c->next) {
|
||||||
if (!get_eq()(key, B::get_key(c->value))) {
|
if (!get_eq()(key, B::get_key(c->value))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
--p_len;
|
--p_len;
|
||||||
Size hh = h;
|
size_t hh = h;
|
||||||
Chain *next = c->next;
|
Chain *next = c->next;
|
||||||
for (; cp[hh] == c; --hh) {
|
for (; cp[hh] == c; --hh) {
|
||||||
cp[hh] = next;
|
cp[hh] = next;
|
||||||
|
@ -635,13 +635,13 @@ public:
|
||||||
return olen - p_len;
|
return olen - p_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size count(const K &key) {
|
size_t count(const K &key) {
|
||||||
Size h = 0;
|
size_t h = 0;
|
||||||
Chain *c = find(key, h);
|
Chain *c = find(key, h);
|
||||||
if (!c) {
|
if (!c) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Size ret = 1;
|
size_t ret = 1;
|
||||||
if (!Multihash) {
|
if (!Multihash) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -654,12 +654,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
Range find(const K &key) {
|
Range find(const K &key) {
|
||||||
Size h = 0;
|
size_t h = 0;
|
||||||
return Range(find(key, h));
|
return Range(find(key, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstRange find(const K &key) const {
|
ConstRange find(const K &key) const {
|
||||||
Size h = 0;
|
size_t h = 0;
|
||||||
return ConstRange(reinterpret_cast<detail::HashChain<const E> *>(
|
return ConstRange(reinterpret_cast<detail::HashChain<const E> *>(
|
||||||
find(key, h)
|
find(key, h)
|
||||||
));
|
));
|
||||||
|
@ -669,14 +669,14 @@ public:
|
||||||
float max_load_factor() const { return p_maxlf; }
|
float max_load_factor() const { return p_maxlf; }
|
||||||
void max_load_factor(float lf) { p_maxlf = lf; }
|
void max_load_factor(float lf) { p_maxlf = lf; }
|
||||||
|
|
||||||
void rehash(Size count) {
|
void rehash(size_t count) {
|
||||||
Size fbcount = Size(p_len / max_load_factor());
|
size_t fbcount = size_t(p_len / max_load_factor());
|
||||||
if (fbcount > count) {
|
if (fbcount > count) {
|
||||||
count = fbcount;
|
count = fbcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chain **och = p_data.first();
|
Chain **och = p_data.first();
|
||||||
Size osize = p_size;
|
size_t osize = p_size;
|
||||||
|
|
||||||
p_size = count;
|
p_size = count;
|
||||||
init_buckets();
|
init_buckets();
|
||||||
|
@ -684,7 +684,7 @@ public:
|
||||||
Chain *p = och ? *och : nullptr;
|
Chain *p = och ? *och : nullptr;
|
||||||
while (p) {
|
while (p) {
|
||||||
Chain *pp = p->next;
|
Chain *pp = p->next;
|
||||||
Size h = bucket(B::get_key(p->value));
|
size_t h = bucket(B::get_key(p->value));
|
||||||
p->prev = p->next = nullptr;
|
p->prev = p->next = nullptr;
|
||||||
insert_node(h, p);
|
insert_node(h, p);
|
||||||
p = pp;
|
p = pp;
|
||||||
|
@ -695,8 +695,8 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void reserve(Size count) {
|
void reserve(size_t count) {
|
||||||
rehash(Size(ceil(count / max_load_factor())));
|
rehash(size_t(ceil(count / max_load_factor())));
|
||||||
}
|
}
|
||||||
|
|
||||||
Range iter() {
|
Range iter() {
|
||||||
|
@ -720,13 +720,13 @@ public:
|
||||||
return ConstRange(reinterpret_cast<Chain *>(*p_data.first()));
|
return ConstRange(reinterpret_cast<Chain *>(*p_data.first()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalRange iter(Size n) {
|
LocalRange iter(size_t n) {
|
||||||
if (n >= p_size) {
|
if (n >= p_size) {
|
||||||
return LocalRange();
|
return LocalRange();
|
||||||
}
|
}
|
||||||
return LocalRange(p_data.first()[n], p_data.first()[n + 1]);
|
return LocalRange(p_data.first()[n], p_data.first()[n + 1]);
|
||||||
}
|
}
|
||||||
ConstLocalRange iter(Size n) const {
|
ConstLocalRange iter(size_t n) const {
|
||||||
using Chain = detail::HashChain<const E>;
|
using Chain = detail::HashChain<const E>;
|
||||||
if (n >= p_size) {
|
if (n >= p_size) {
|
||||||
return ConstLocalRange();
|
return ConstLocalRange();
|
||||||
|
@ -736,7 +736,7 @@ public:
|
||||||
reinterpret_cast<Chain *>(p_data.first()[n + 1])
|
reinterpret_cast<Chain *>(p_data.first()[n + 1])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ConstLocalRange citer(Size n) const {
|
ConstLocalRange citer(size_t n) const {
|
||||||
using Chain = detail::HashChain<const E>;
|
using Chain = detail::HashChain<const E>;
|
||||||
if (n >= p_size) {
|
if (n >= p_size) {
|
||||||
return ConstLocalRange();
|
return ConstLocalRange();
|
||||||
|
|
12
ostd/io.hh
12
ostd/io.hh
|
@ -59,9 +59,9 @@ struct FileStream: Stream {
|
||||||
buf[path.size()] = '\0';
|
buf[path.size()] = '\0';
|
||||||
p_owned = false;
|
p_owned = false;
|
||||||
#ifndef OSTD_PLATFORM_WIN32
|
#ifndef OSTD_PLATFORM_WIN32
|
||||||
p_f = fopen(buf, detail::filemodes[Size(mode)]);
|
p_f = fopen(buf, detail::filemodes[size_t(mode)]);
|
||||||
#else
|
#else
|
||||||
if (fopen_s(&p_f, buf, detail::filemodes[Size(mode)]) != 0) {
|
if (fopen_s(&p_f, buf, detail::filemodes[size_t(mode)]) != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -111,11 +111,11 @@ struct FileStream: Stream {
|
||||||
|
|
||||||
bool flush() { return !fflush(p_f); }
|
bool flush() { return !fflush(p_f); }
|
||||||
|
|
||||||
Size read_bytes(void *buf, Size count) {
|
size_t read_bytes(void *buf, size_t count) {
|
||||||
return fread(buf, 1, count, p_f);
|
return fread(buf, 1, count, p_f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Size write_bytes(void const *buf, Size count) {
|
size_t write_bytes(void const *buf, size_t count) {
|
||||||
return fwrite(buf, 1, count, p_f);
|
return fwrite(buf, 1, count, p_f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,12 +194,12 @@ inline void writeln(T const &v, A const &...args) {
|
||||||
template<typename ...A>
|
template<typename ...A>
|
||||||
inline void writef(ConstCharRange fmt, A const &...args) {
|
inline void writef(ConstCharRange fmt, A const &...args) {
|
||||||
char buf[512];
|
char buf[512];
|
||||||
Ptrdiff need = format(
|
ptrdiff_t need = format(
|
||||||
detail::FormatOutRange<sizeof(buf)>(buf), fmt, args...
|
detail::FormatOutRange<sizeof(buf)>(buf), fmt, args...
|
||||||
);
|
);
|
||||||
if (need < 0) {
|
if (need < 0) {
|
||||||
return;
|
return;
|
||||||
} else if (Size(need) < sizeof(buf)) {
|
} else if (size_t(need) < sizeof(buf)) {
|
||||||
fwrite(buf, 1, need, stdout);
|
fwrite(buf, 1, need, stdout);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ namespace detail {
|
||||||
public:
|
public:
|
||||||
using Key = KeysetKey<T>;
|
using Key = KeysetKey<T>;
|
||||||
using Mapped = T;
|
using Mapped = T;
|
||||||
using Size = ostd::Size;
|
using Size = size_t;
|
||||||
using Difference = Ptrdiff;
|
using Difference = ptrdiff_t;
|
||||||
using Hasher = H;
|
using Hasher = H;
|
||||||
using KeyEqual = C;
|
using KeyEqual = C;
|
||||||
using Value = T;
|
using Value = T;
|
||||||
|
|
|
@ -55,8 +55,8 @@ namespace detail {
|
||||||
public:
|
public:
|
||||||
using Key = K;
|
using Key = K;
|
||||||
using Mapped = T;
|
using Mapped = T;
|
||||||
using Size = ostd::Size;
|
using Size = size_t;
|
||||||
using Difference = Ptrdiff;
|
using Difference = ptrdiff_t;
|
||||||
using Hasher = H;
|
using Hasher = H;
|
||||||
using KeyEqual = C;
|
using KeyEqual = C;
|
||||||
using Value = std::pair<K const, T>;
|
using Value = std::pair<K const, T>;
|
||||||
|
|
|
@ -75,7 +75,7 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T, bool = HasDifference<T>::value>
|
template<typename T, bool = HasDifference<T>::value>
|
||||||
struct PointerDifferenceBase {
|
struct PointerDifferenceBase {
|
||||||
using Type = Ptrdiff;
|
using Type = ptrdiff_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -90,7 +90,7 @@ namespace detail {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct PointerDifferenceType<T *> {
|
struct PointerDifferenceType<T *> {
|
||||||
using Type = Ptrdiff;
|
using Type = ptrdiff_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
|
@ -225,11 +225,11 @@ struct Allocator {
|
||||||
template<typename U>
|
template<typename U>
|
||||||
Allocator(Allocator<U> const &) noexcept {}
|
Allocator(Allocator<U> const &) noexcept {}
|
||||||
|
|
||||||
Value *allocate(Size n) {
|
Value *allocate(size_t n) {
|
||||||
return reinterpret_cast<Value *>(::new byte[n * sizeof(T)]);
|
return reinterpret_cast<Value *>(::new byte[n * sizeof(T)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocate(Value *p, Size) noexcept {
|
void deallocate(Value *p, size_t) noexcept {
|
||||||
::delete[] reinterpret_cast<byte *>(p);
|
::delete[] reinterpret_cast<byte *>(p);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -752,7 +752,7 @@ namespace detail {
|
||||||
template<typename A>
|
template<typename A>
|
||||||
struct AllocatorDestructor {
|
struct AllocatorDestructor {
|
||||||
using Pointer = AllocatorPointer<A>;
|
using Pointer = AllocatorPointer<A>;
|
||||||
using Size = ostd::Size;
|
using Size = size_t;
|
||||||
AllocatorDestructor(A &a, Size s) noexcept: p_alloc(a), p_size(s) {}
|
AllocatorDestructor(A &a, Size s) noexcept: p_alloc(a), p_size(s) {}
|
||||||
void operator()(Pointer p) noexcept {
|
void operator()(Pointer p) noexcept {
|
||||||
allocator_deallocate(p_alloc, p, p_size);
|
allocator_deallocate(p_alloc, p, p_size);
|
||||||
|
|
|
@ -507,7 +507,7 @@ struct ZipRange;
|
||||||
|
|
||||||
template<
|
template<
|
||||||
typename B, typename C, typename V, typename R = V &,
|
typename B, typename C, typename V, typename R = V &,
|
||||||
typename S = Size, typename D = Ptrdiff
|
typename S = size_t, typename D = ptrdiff_t
|
||||||
>
|
>
|
||||||
struct InputRange {
|
struct InputRange {
|
||||||
using Category = C;
|
using Category = C;
|
||||||
|
@ -689,7 +689,7 @@ inline auto chunks(T n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T, typename ...R, Size ...I>
|
template<typename T, typename ...R, size_t ...I>
|
||||||
inline auto join_proxy(
|
inline auto join_proxy(
|
||||||
T &&obj, std::tuple<R &&...> &&tup, std::index_sequence<I...>
|
T &&obj, std::tuple<R &&...> &&tup, std::index_sequence<I...>
|
||||||
) {
|
) {
|
||||||
|
@ -698,7 +698,7 @@ namespace detail {
|
||||||
)...);
|
)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename ...R, Size ...I>
|
template<typename T, typename ...R, size_t ...I>
|
||||||
inline auto zip_proxy(
|
inline auto zip_proxy(
|
||||||
T &&obj, std::tuple<R &&...> &&tup, std::index_sequence<I...>
|
T &&obj, std::tuple<R &&...> &&tup, std::index_sequence<I...>
|
||||||
) {
|
) {
|
||||||
|
@ -790,7 +790,7 @@ inline auto citer(T const &r) -> decltype(ranged_traits<T const>::iter(r)) {
|
||||||
|
|
||||||
template<
|
template<
|
||||||
typename B, typename V, typename R = V &,
|
typename B, typename V, typename R = V &,
|
||||||
typename S = Size, typename D = Ptrdiff
|
typename S = size_t, typename D = ptrdiff_t
|
||||||
>
|
>
|
||||||
struct OutputRange {
|
struct OutputRange {
|
||||||
using Category = OutputRangeTag;
|
using Category = OutputRangeTag;
|
||||||
|
@ -1100,7 +1100,7 @@ public:
|
||||||
(IsPointer<U> || IsNullPointer<U>) && IsConvertible<U, T *>, Nat
|
(IsPointer<U> || IsNullPointer<U>) && IsConvertible<U, T *>, Nat
|
||||||
> = Nat()): p_beg(beg), p_end(end) {}
|
> = Nat()): p_beg(beg), p_end(end) {}
|
||||||
|
|
||||||
PointerRange(T *beg, Size n): p_beg(beg), p_end(beg + n) {}
|
PointerRange(T *beg, size_t n): p_beg(beg), p_end(beg + n) {}
|
||||||
|
|
||||||
template<typename U, typename = EnableIf<IsConvertible<U *, T *>>>
|
template<typename U, typename = EnableIf<IsConvertible<U *, T *>>>
|
||||||
PointerRange(PointerRange<U> const &v): p_beg(&v[0]), p_end(&v[v.size()]) {}
|
PointerRange(PointerRange<U> const &v): p_beg(&v[0]), p_end(&v[v.size()]) {}
|
||||||
|
@ -1125,8 +1125,8 @@ public:
|
||||||
--p_beg; return true;
|
--p_beg; return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size pop_front_n(Size n) {
|
size_t pop_front_n(size_t n) {
|
||||||
Size olen = p_end - p_beg;
|
size_t olen = p_end - p_beg;
|
||||||
p_beg += n;
|
p_beg += n;
|
||||||
if (p_beg > p_end) {
|
if (p_beg > p_end) {
|
||||||
p_beg = p_end;
|
p_beg = p_end;
|
||||||
|
@ -1135,7 +1135,7 @@ public:
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size push_front_n(Size n) {
|
size_t push_front_n(size_t n) {
|
||||||
p_beg -= n; return true;
|
p_beg -= n; return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1145,7 +1145,7 @@ public:
|
||||||
return p_beg == range.p_beg;
|
return p_beg == range.p_beg;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptrdiff distance_front(PointerRange const &range) const {
|
ptrdiff_t distance_front(PointerRange const &range) const {
|
||||||
return range.p_beg - p_beg;
|
return range.p_beg - p_beg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1161,8 +1161,8 @@ public:
|
||||||
++p_end; return true;
|
++p_end; return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size pop_back_n(Size n) {
|
size_t pop_back_n(size_t n) {
|
||||||
Size olen = p_end - p_beg;
|
size_t olen = p_end - p_beg;
|
||||||
p_end -= n;
|
p_end -= n;
|
||||||
if (p_end < p_beg) {
|
if (p_end < p_beg) {
|
||||||
p_end = p_beg;
|
p_end = p_beg;
|
||||||
|
@ -1171,7 +1171,7 @@ public:
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size push_back_n(Size n) {
|
size_t push_back_n(size_t n) {
|
||||||
p_end += n; return true;
|
p_end += n; return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1181,18 +1181,18 @@ public:
|
||||||
return p_end == range.p_end;
|
return p_end == range.p_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptrdiff distance_back(PointerRange const &range) const {
|
ptrdiff_t distance_back(PointerRange const &range) const {
|
||||||
return range.p_end - p_end;
|
return range.p_end - p_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* satisfy FiniteRandomAccessRange */
|
/* satisfy FiniteRandomAccessRange */
|
||||||
Size size() const { return p_end - p_beg; }
|
size_t size() const { return p_end - p_beg; }
|
||||||
|
|
||||||
PointerRange slice(Size start, Size end) const {
|
PointerRange slice(size_t start, size_t end) const {
|
||||||
return PointerRange(p_beg + start, p_beg + end);
|
return PointerRange(p_beg + start, p_beg + end);
|
||||||
}
|
}
|
||||||
|
|
||||||
T &operator[](Size i) const { return p_beg[i]; }
|
T &operator[](size_t i) const { return p_beg[i]; }
|
||||||
|
|
||||||
/* satisfy OutputRange */
|
/* satisfy OutputRange */
|
||||||
bool put(T const &v) {
|
bool put(T const &v) {
|
||||||
|
@ -1210,8 +1210,8 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size put_n(T const *p, Size n) {
|
size_t put_n(T const *p, size_t n) {
|
||||||
Size ret = size();
|
size_t ret = size();
|
||||||
if (n < ret) {
|
if (n < ret) {
|
||||||
ret = n;
|
ret = n;
|
||||||
}
|
}
|
||||||
|
@ -1220,23 +1220,23 @@ public:
|
||||||
p_beg += ret;
|
p_beg += ret;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
for (Size i = ret; i; --i) {
|
for (size_t i = ret; i; --i) {
|
||||||
*p_beg++ = *p++;
|
*p_beg++ = *p++;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R>
|
template<typename R>
|
||||||
EnableIf<IsOutputRange<R>, Size> copy(R &&orange, Size n = -1) {
|
EnableIf<IsOutputRange<R>, size_t> copy(R &&orange, size_t n = -1) {
|
||||||
Size c = size();
|
size_t c = size();
|
||||||
if (n < c) {
|
if (n < c) {
|
||||||
c = n;
|
c = n;
|
||||||
}
|
}
|
||||||
return orange.put_n(p_beg, c);
|
return orange.put_n(p_beg, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
Size copy(RemoveCv<T> *p, Size n = -1) {
|
size_t copy(RemoveCv<T> *p, size_t n = -1) {
|
||||||
Size c = size();
|
size_t c = size();
|
||||||
if (n < c) {
|
if (n < c) {
|
||||||
c = n;
|
c = n;
|
||||||
}
|
}
|
||||||
|
@ -1254,17 +1254,17 @@ private:
|
||||||
T *p_beg, *p_end;
|
T *p_beg, *p_end;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, Size N>
|
template<typename T, size_t N>
|
||||||
inline PointerRange<T> iter(T (&array)[N]) {
|
inline PointerRange<T> iter(T (&array)[N]) {
|
||||||
return PointerRange<T>(array, N);
|
return PointerRange<T>(array, N);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, Size N>
|
template<typename T, size_t N>
|
||||||
inline PointerRange<T const> iter(T const (&array)[N]) {
|
inline PointerRange<T const> iter(T const (&array)[N]) {
|
||||||
return PointerRange<T const>(array, N);
|
return PointerRange<T const>(array, N);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, Size N>
|
template<typename T, size_t N>
|
||||||
inline PointerRange<T const> citer(T const (&array)[N]) {
|
inline PointerRange<T const> citer(T const (&array)[N]) {
|
||||||
return PointerRange<T const>(array, N);
|
return PointerRange<T const>(array, N);
|
||||||
}
|
}
|
||||||
|
@ -1281,7 +1281,7 @@ inline PointerRange<T> iter(T *a, U b, EnableIf<
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline PointerRange<T> iter(T *a, ostd::Size b) {
|
inline PointerRange<T> iter(T *a, size_t b) {
|
||||||
return PointerRange<T>(a, b);
|
return PointerRange<T>(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1459,7 +1459,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<Size I, Size N>
|
template<size_t I, size_t N>
|
||||||
struct JoinRangeEmpty {
|
struct JoinRangeEmpty {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool empty(T const &tup) {
|
static bool empty(T const &tup) {
|
||||||
|
@ -1470,7 +1470,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct JoinRangeEmpty<N, N> {
|
struct JoinRangeEmpty<N, N> {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool empty(T const &) {
|
static bool empty(T const &) {
|
||||||
|
@ -1478,7 +1478,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size I, Size N>
|
template<size_t I, size_t N>
|
||||||
struct TupleRangeEqual {
|
struct TupleRangeEqual {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool equal(T const &tup1, T const &tup2) {
|
static bool equal(T const &tup1, T const &tup2) {
|
||||||
|
@ -1489,7 +1489,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct TupleRangeEqual<N, N> {
|
struct TupleRangeEqual<N, N> {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool equal(T const &, T const &) {
|
static bool equal(T const &, T const &) {
|
||||||
|
@ -1497,7 +1497,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size I, Size N>
|
template<size_t I, size_t N>
|
||||||
struct JoinRangePop {
|
struct JoinRangePop {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool pop(T &tup) {
|
static bool pop(T &tup) {
|
||||||
|
@ -1508,7 +1508,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct JoinRangePop<N, N> {
|
struct JoinRangePop<N, N> {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool pop(T &) {
|
static bool pop(T &) {
|
||||||
|
@ -1516,7 +1516,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size I, Size N, typename T>
|
template<size_t I, size_t N, typename T>
|
||||||
struct JoinRangeFront {
|
struct JoinRangeFront {
|
||||||
template<typename U>
|
template<typename U>
|
||||||
static T front(U const &tup) {
|
static T front(U const &tup) {
|
||||||
|
@ -1527,7 +1527,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size N, typename T>
|
template<size_t N, typename T>
|
||||||
struct JoinRangeFront<N, N, T> {
|
struct JoinRangeFront<N, N, T> {
|
||||||
template<typename U>
|
template<typename U>
|
||||||
static T front(U const &tup) {
|
static T front(U const &tup) {
|
||||||
|
@ -1595,7 +1595,7 @@ namespace detail {
|
||||||
template<typename ...T>
|
template<typename ...T>
|
||||||
using ZipValue = typename detail::ZipValueType<T...>::Type;
|
using ZipValue = typename detail::ZipValueType<T...>::Type;
|
||||||
|
|
||||||
template<Size I, Size N>
|
template<size_t I, size_t N>
|
||||||
struct ZipRangeEmpty {
|
struct ZipRangeEmpty {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool empty(T const &tup) {
|
static bool empty(T const &tup) {
|
||||||
|
@ -1606,7 +1606,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct ZipRangeEmpty<N, N> {
|
struct ZipRangeEmpty<N, N> {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool empty(T const &) {
|
static bool empty(T const &) {
|
||||||
|
@ -1614,7 +1614,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size I, Size N>
|
template<size_t I, size_t N>
|
||||||
struct ZipRangePop {
|
struct ZipRangePop {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool pop(T &tup) {
|
static bool pop(T &tup) {
|
||||||
|
@ -1624,7 +1624,7 @@ namespace detail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct ZipRangePop<N, N> {
|
struct ZipRangePop<N, N> {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static bool pop(T &) {
|
static bool pop(T &) {
|
||||||
|
@ -1634,7 +1634,7 @@ namespace detail {
|
||||||
|
|
||||||
template<typename ...T>
|
template<typename ...T>
|
||||||
struct ZipRangeFront {
|
struct ZipRangeFront {
|
||||||
template<typename U, Size ...I>
|
template<typename U, size_t ...I>
|
||||||
static ZipValue<T...> tup_get(U const &tup, std::index_sequence<I...>) {
|
static ZipValue<T...> tup_get(U const &tup, std::index_sequence<I...>) {
|
||||||
return ZipValue<T...>(std::get<I>(tup).front()...);
|
return ZipValue<T...>(std::get<I>(tup).front()...);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,8 @@ namespace detail {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Key = T;
|
using Key = T;
|
||||||
using Size = ostd::Size;
|
using Size = size_t;
|
||||||
using Difference = Ptrdiff;
|
using Difference = ptrdiff_t;
|
||||||
using Hasher = H;
|
using Hasher = H;
|
||||||
using KeyEqual = C;
|
using KeyEqual = C;
|
||||||
using Value = T;
|
using Value = T;
|
||||||
|
|
|
@ -36,12 +36,12 @@ template<typename T = char, bool = IsPod<T>>
|
||||||
struct StreamRange;
|
struct StreamRange;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct FormatOutRange: OutputRange<FormatOutRange<N>, char> {
|
struct FormatOutRange: OutputRange<FormatOutRange<N>, char> {
|
||||||
FormatOutRange(char *ibuf): buf(ibuf), idx(0) {}
|
FormatOutRange(char *ibuf): buf(ibuf), idx(0) {}
|
||||||
FormatOutRange(FormatOutRange const &r): buf(r.buf), idx(r.idx) {}
|
FormatOutRange(FormatOutRange const &r): buf(r.buf), idx(r.idx) {}
|
||||||
char *buf;
|
char *buf;
|
||||||
Size idx;
|
size_t idx;
|
||||||
bool put(char v) {
|
bool put(char v) {
|
||||||
if (idx < N) {
|
if (idx < N) {
|
||||||
buf[idx++] = v;
|
buf[idx++] = v;
|
||||||
|
@ -104,8 +104,8 @@ public:
|
||||||
|
|
||||||
virtual bool flush() { return true; }
|
virtual bool flush() { return true; }
|
||||||
|
|
||||||
virtual Size read_bytes(void *, Size) { return 0; }
|
virtual size_t read_bytes(void *, size_t) { return 0; }
|
||||||
virtual Size write_bytes(void const *, Size) { return 0; }
|
virtual size_t write_bytes(void const *, size_t) { return 0; }
|
||||||
|
|
||||||
virtual int getchar() {
|
virtual int getchar() {
|
||||||
byte c;
|
byte c;
|
||||||
|
@ -140,18 +140,18 @@ public:
|
||||||
template<typename ...A>
|
template<typename ...A>
|
||||||
bool writef(ConstCharRange fmt, A const &...args) {
|
bool writef(ConstCharRange fmt, A const &...args) {
|
||||||
char buf[512];
|
char buf[512];
|
||||||
Ptrdiff need = format(
|
ptrdiff_t need = format(
|
||||||
detail::FormatOutRange<sizeof(buf)>(buf), fmt, args...
|
detail::FormatOutRange<sizeof(buf)>(buf), fmt, args...
|
||||||
);
|
);
|
||||||
if (need < 0) {
|
if (need < 0) {
|
||||||
return false;
|
return false;
|
||||||
} else if (Size(need) < sizeof(buf)) {
|
} else if (size_t(need) < sizeof(buf)) {
|
||||||
return write_bytes(buf, need) == Size(need);
|
return write_bytes(buf, need) == size_t(need);
|
||||||
}
|
}
|
||||||
std::vector<char> s;
|
std::vector<char> s;
|
||||||
s.reserve(need);
|
s.reserve(need);
|
||||||
format(detail::UnsafeWritefRange(s.data()), fmt, args...);
|
format(detail::UnsafeWritefRange(s.data()), fmt, args...);
|
||||||
return write_bytes(s.data(), need) == Size(need);
|
return write_bytes(s.data(), need) == size_t(need);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ...A>
|
template<typename ...A>
|
||||||
|
@ -163,7 +163,7 @@ public:
|
||||||
StreamRange<T> iter();
|
StreamRange<T> iter();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Size put(T const *v, Size count) {
|
size_t put(T const *v, size_t count) {
|
||||||
return write_bytes(v, count * sizeof(T)) / sizeof(T);
|
return write_bytes(v, count * sizeof(T)) / sizeof(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Size get(T *v, Size count) {
|
size_t get(T *v, size_t count) {
|
||||||
return read_bytes(v, count * sizeof(T)) / sizeof(T);
|
return read_bytes(v, count * sizeof(T)) / sizeof(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ public:
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct StreamRange<T, true>: InputRange<
|
struct StreamRange<T, true>: InputRange<
|
||||||
StreamRange<T>, InputRangeTag, T, T, Size, StreamOffset
|
StreamRange<T>, InputRangeTag, T, T, size_t, StreamOffset
|
||||||
> {
|
> {
|
||||||
StreamRange() = delete;
|
StreamRange() = delete;
|
||||||
StreamRange(Stream &s): p_stream(&s), p_size(s.size()) {}
|
StreamRange(Stream &s): p_stream(&s), p_size(s.size()) {}
|
||||||
|
@ -220,17 +220,17 @@ struct StreamRange<T, true>: InputRange<
|
||||||
}
|
}
|
||||||
|
|
||||||
bool put(T val) {
|
bool put(T val) {
|
||||||
Size v = p_stream->write_bytes(&val, sizeof(T));
|
size_t v = p_stream->write_bytes(&val, sizeof(T));
|
||||||
p_size += v;
|
p_size += v;
|
||||||
return (v == sizeof(T));
|
return (v == sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
Size put_n(T const *p, Size n) {
|
size_t put_n(T const *p, size_t n) {
|
||||||
return p_stream->put(p, n);
|
return p_stream->put(p, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
Size copy(RemoveCv<T> *p, Size n = -1) {
|
size_t copy(RemoveCv<T> *p, size_t n = -1) {
|
||||||
if (n == Size(-1)) {
|
if (n == size_t(-1)) {
|
||||||
n = p_stream->size() / sizeof(T);
|
n = p_stream->size() / sizeof(T);
|
||||||
}
|
}
|
||||||
return p_stream->get(p, n);
|
return p_stream->get(p, n);
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
(IsPointer<U> || IsNullPointer<U>) && IsConvertible<U, T *>, Nat
|
(IsPointer<U> || IsNullPointer<U>) && IsConvertible<U, T *>, Nat
|
||||||
> = Nat()): p_beg(beg), p_end(end) {}
|
> = Nat()): p_beg(beg), p_end(end) {}
|
||||||
|
|
||||||
CharRangeBase(T *beg, Size n): p_beg(beg), p_end(beg + n) {}
|
CharRangeBase(T *beg, size_t n): p_beg(beg), p_end(beg + n) {}
|
||||||
|
|
||||||
/* TODO: traits for utf-16/utf-32 string lengths, for now assume char */
|
/* TODO: traits for utf-16/utf-32 string lengths, for now assume char */
|
||||||
template<typename U>
|
template<typename U>
|
||||||
|
@ -47,7 +47,7 @@ public:
|
||||||
|
|
||||||
CharRangeBase(Nullptr): p_beg(nullptr), p_end(nullptr) {}
|
CharRangeBase(Nullptr): p_beg(nullptr), p_end(nullptr) {}
|
||||||
|
|
||||||
template<typename U, Size N>
|
template<typename U, size_t N>
|
||||||
CharRangeBase(U (&beg)[N], EnableIf<IsConvertible<U *, T *>, Nat> = Nat()):
|
CharRangeBase(U (&beg)[N], EnableIf<IsConvertible<U *, T *>, Nat> = Nat()):
|
||||||
p_beg(beg), p_end(beg + N - (beg[N - 1] == '\0'))
|
p_beg(beg), p_end(beg + N - (beg[N - 1] == '\0'))
|
||||||
{}
|
{}
|
||||||
|
@ -88,8 +88,8 @@ public:
|
||||||
}
|
}
|
||||||
bool push_front() { --p_beg; return true; }
|
bool push_front() { --p_beg; return true; }
|
||||||
|
|
||||||
Size pop_front_n(Size n) {
|
size_t pop_front_n(size_t n) {
|
||||||
Size olen = p_end - p_beg;
|
size_t olen = p_end - p_beg;
|
||||||
p_beg += n;
|
p_beg += n;
|
||||||
if (p_beg > p_end) {
|
if (p_beg > p_end) {
|
||||||
p_beg = p_end;
|
p_beg = p_end;
|
||||||
|
@ -98,7 +98,7 @@ public:
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size push_front_n(Size n) { p_beg -= n; return true; }
|
size_t push_front_n(size_t n) { p_beg -= n; return true; }
|
||||||
|
|
||||||
T &front() const { return *p_beg; }
|
T &front() const { return *p_beg; }
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public:
|
||||||
return p_beg == range.p_beg;
|
return p_beg == range.p_beg;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptrdiff distance_front(CharRangeBase const &range) const {
|
ptrdiff_t distance_front(CharRangeBase const &range) const {
|
||||||
return range.p_beg - p_beg;
|
return range.p_beg - p_beg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,8 +119,8 @@ public:
|
||||||
}
|
}
|
||||||
bool push_back() { ++p_end; return true; }
|
bool push_back() { ++p_end; return true; }
|
||||||
|
|
||||||
Size pop_back_n(Size n) {
|
size_t pop_back_n(size_t n) {
|
||||||
Size olen = p_end - p_beg;
|
size_t olen = p_end - p_beg;
|
||||||
p_end -= n;
|
p_end -= n;
|
||||||
if (p_end < p_beg) {
|
if (p_end < p_beg) {
|
||||||
p_end = p_beg;
|
p_end = p_beg;
|
||||||
|
@ -129,7 +129,7 @@ public:
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size push_back_n(Size n) { p_end += n; return true; }
|
size_t push_back_n(size_t n) { p_end += n; return true; }
|
||||||
|
|
||||||
T &back() const { return *(p_end - 1); }
|
T &back() const { return *(p_end - 1); }
|
||||||
|
|
||||||
|
@ -137,17 +137,17 @@ public:
|
||||||
return p_end == range.p_end;
|
return p_end == range.p_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptrdiff distance_back(CharRangeBase const &range) const {
|
ptrdiff_t distance_back(CharRangeBase const &range) const {
|
||||||
return range.p_end - p_end;
|
return range.p_end - p_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size size() const { return p_end - p_beg; }
|
size_t size() const { return p_end - p_beg; }
|
||||||
|
|
||||||
CharRangeBase slice(Size start, Size end) const {
|
CharRangeBase slice(size_t start, size_t end) const {
|
||||||
return CharRangeBase(p_beg + start, p_beg + end);
|
return CharRangeBase(p_beg + start, p_beg + end);
|
||||||
}
|
}
|
||||||
|
|
||||||
T &operator[](Size i) const { return p_beg[i]; }
|
T &operator[](size_t i) const { return p_beg[i]; }
|
||||||
|
|
||||||
bool put(T v) {
|
bool put(T v) {
|
||||||
if (empty()) {
|
if (empty()) {
|
||||||
|
@ -157,8 +157,8 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size put_n(T const *p, Size n) {
|
size_t put_n(T const *p, size_t n) {
|
||||||
Size an = ostd::min(n, size());
|
size_t an = ostd::min(n, size());
|
||||||
memcpy(p_beg, p, an * sizeof(T));
|
memcpy(p_beg, p, an * sizeof(T));
|
||||||
p_beg += an;
|
p_beg += an;
|
||||||
return an;
|
return an;
|
||||||
|
@ -169,7 +169,7 @@ public:
|
||||||
|
|
||||||
/* non-range */
|
/* non-range */
|
||||||
int compare(CharRangeBase<T const> s) const {
|
int compare(CharRangeBase<T const> s) const {
|
||||||
ostd::Size s1 = size(), s2 = s.size();
|
size_t s1 = size(), s2 = s.size();
|
||||||
int ret;
|
int ret;
|
||||||
if (!s1 || !s2) {
|
if (!s1 || !s2) {
|
||||||
goto diffsize;
|
goto diffsize;
|
||||||
|
@ -182,8 +182,8 @@ diffsize:
|
||||||
}
|
}
|
||||||
|
|
||||||
int case_compare(CharRangeBase<T const> s) const {
|
int case_compare(CharRangeBase<T const> s) const {
|
||||||
ostd::Size s1 = size(), s2 = s.size();
|
size_t s1 = size(), s2 = s.size();
|
||||||
for (ostd::Size i = 0, ms = ostd::min(s1, s2); i < ms; ++i) {
|
for (size_t i = 0, ms = ostd::min(s1, s2); i < ms; ++i) {
|
||||||
int d = toupper(p_beg[i]) - toupper(s[i]);
|
int d = toupper(p_beg[i]) - toupper(s[i]);
|
||||||
if (d) {
|
if (d) {
|
||||||
return d;
|
return d;
|
||||||
|
@ -193,12 +193,12 @@ diffsize:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename R>
|
template<typename R>
|
||||||
EnableIf<IsOutputRange<R>, Size> copy(R &&orange, Size n = -1) {
|
EnableIf<IsOutputRange<R>, size_t> copy(R &&orange, size_t n = -1) {
|
||||||
return orange.put_n(data(), ostd::min(n, size()));
|
return orange.put_n(data(), ostd::min(n, size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Size copy(RemoveCv<T> *p, Size n = -1) {
|
size_t copy(RemoveCv<T> *p, size_t n = -1) {
|
||||||
Size c = ostd::min(n, size());
|
size_t c = ostd::min(n, size());
|
||||||
memcpy(p, data(), c * sizeof(T));
|
memcpy(p, data(), c * sizeof(T));
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ inline std::basic_string<RemoveCv<RangeValue<R>>> make_string(R range) {
|
||||||
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
inline namespace string_literals {
|
inline namespace string_literals {
|
||||||
inline ConstCharRange operator "" _sr(char const *str, Size len) {
|
inline ConstCharRange operator "" _sr(char const *str, size_t len) {
|
||||||
return ConstCharRange(str, len);
|
return ConstCharRange(str, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,18 +370,18 @@ namespace detail {
|
||||||
p_written += ret;
|
p_written += ret;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
Size put_n(char const *v, Size n) {
|
size_t put_n(char const *v, size_t n) {
|
||||||
Size ret = p_out.put_n(v, n);
|
size_t ret = p_out.put_n(v, n);
|
||||||
p_written += ret;
|
p_written += ret;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
Size put_string(ConstCharRange r) {
|
size_t put_string(ConstCharRange r) {
|
||||||
return put_n(&r[0], r.size());
|
return put_n(&r[0], r.size());
|
||||||
}
|
}
|
||||||
Size get_written() const { return p_written; }
|
size_t get_written() const { return p_written; }
|
||||||
private:
|
private:
|
||||||
R &p_out;
|
R &p_out;
|
||||||
Size p_written;
|
size_t p_written;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename R>
|
template<typename T, typename R>
|
||||||
|
@ -565,7 +565,7 @@ struct ToString<std::pair<T, U>> {
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<Size I, Size N>
|
template<size_t I, size_t N>
|
||||||
struct TupleToString {
|
struct TupleToString {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void append(std::string &ret, T const &tup) {
|
static void append(std::string &ret, T const &tup) {
|
||||||
|
@ -577,13 +577,13 @@ namespace detail {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct TupleToString<N, N> {
|
struct TupleToString<N, N> {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void append(std::string &, T const &) {}
|
static void append(std::string &, T const &) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct TupleToString<0, N> {
|
struct TupleToString<0, N> {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void append(std::string &ret, T const &tup) {
|
static void append(std::string &ret, T const &tup) {
|
||||||
|
@ -630,7 +630,7 @@ public:
|
||||||
s.p_buf = nullptr;
|
s.p_buf = nullptr;
|
||||||
s.p_allocated = false;
|
s.p_allocated = false;
|
||||||
}
|
}
|
||||||
TempCString(R input, RemoveCv<RangeValue<R>> *sbuf, Size bufsize)
|
TempCString(R input, RemoveCv<RangeValue<R>> *sbuf, size_t bufsize)
|
||||||
: p_buf(nullptr), p_allocated(false) {
|
: p_buf(nullptr), p_allocated(false) {
|
||||||
if (input.empty()) {
|
if (input.empty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -672,7 +672,7 @@ inline void swap(TempCString<R> &a, TempCString<R> &b) {
|
||||||
|
|
||||||
template<typename R>
|
template<typename R>
|
||||||
inline TempCString<R> to_temp_cstr(
|
inline TempCString<R> to_temp_cstr(
|
||||||
R input, RemoveCv<RangeValue<R>> *buf, Size bufsize
|
R input, RemoveCv<RangeValue<R>> *buf, size_t bufsize
|
||||||
) {
|
) {
|
||||||
return TempCString<R>(input, buf, bufsize);
|
return TempCString<R>(input, buf, bufsize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ using RemoveAllExtents = typename detail::RemoveAllExtentsBase<T>::Type;
|
||||||
/* size in bits */
|
/* size in bits */
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr Size SizeInBits = sizeof(T) * CHAR_BIT;
|
constexpr size_t SizeInBits = sizeof(T) * CHAR_BIT;
|
||||||
|
|
||||||
/* integral constant */
|
/* integral constant */
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ template<typename>
|
||||||
constexpr bool IsArray = false;
|
constexpr bool IsArray = false;
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool IsArray<T[]> = true;
|
constexpr bool IsArray<T[]> = true;
|
||||||
template<typename T, Size N>
|
template<typename T, size_t N>
|
||||||
constexpr bool IsArray<T[N]> = true;
|
constexpr bool IsArray<T[N]> = true;
|
||||||
|
|
||||||
/* is pointer */
|
/* is pointer */
|
||||||
|
@ -679,11 +679,11 @@ namespace detail {
|
||||||
CtibleVoidCheck<CtibleContainsVoid<T, A...> || IsAbstract<T>, T, A...>;
|
CtibleVoidCheck<CtibleContainsVoid<T, A...> || IsAbstract<T>, T, A...>;
|
||||||
|
|
||||||
/* array types are default constructible if their element type is */
|
/* array types are default constructible if their element type is */
|
||||||
template<typename T, Size N>
|
template<typename T, size_t N>
|
||||||
constexpr bool CtibleCore<false, T[N]> = Ctible<RemoveAllExtents<T>>;
|
constexpr bool CtibleCore<false, T[N]> = Ctible<RemoveAllExtents<T>>;
|
||||||
|
|
||||||
/* otherwise array types are not constructible by this syntax */
|
/* otherwise array types are not constructible by this syntax */
|
||||||
template<typename T, Size N, typename ...A>
|
template<typename T, size_t N, typename ...A>
|
||||||
constexpr bool CtibleCore<false, T[N], A...> = false;
|
constexpr bool CtibleCore<false, T[N], A...> = false;
|
||||||
|
|
||||||
/* incomplete array types are not constructible */
|
/* incomplete array types are not constructible */
|
||||||
|
@ -735,7 +735,7 @@ namespace detail {
|
||||||
template<typename T, typename ...A> constexpr bool IsNothrowConstructible =
|
template<typename T, typename ...A> constexpr bool IsNothrowConstructible =
|
||||||
detail::NothrowCtibleCore<IsConstructible<T, A...>, IsReference<T>, T, A...>;
|
detail::NothrowCtibleCore<IsConstructible<T, A...>, IsReference<T>, T, A...>;
|
||||||
|
|
||||||
template<typename T, Size N> constexpr bool IsNothrowConstructible<T[N]> =
|
template<typename T, size_t N> constexpr bool IsNothrowConstructible<T[N]> =
|
||||||
detail::NothrowCtibleCore<IsConstructible<T>, IsReference<T>, T>;
|
detail::NothrowCtibleCore<IsConstructible<T>, IsReference<T>, T>;
|
||||||
|
|
||||||
/* is nothrow default constructible */
|
/* is nothrow default constructible */
|
||||||
|
@ -884,7 +884,7 @@ namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr bool IsNothrowDestructible = detail::NothrowDtibleCore<IsDestructible<T>, T>;
|
constexpr bool IsNothrowDestructible = detail::NothrowDtibleCore<IsDestructible<T>, T>;
|
||||||
|
|
||||||
template<typename T, Size N>
|
template<typename T, size_t N>
|
||||||
constexpr bool IsNothrowDestructible<T[N]> = IsNothrowDestructible<T>;
|
constexpr bool IsNothrowDestructible<T[N]> = IsNothrowDestructible<T>;
|
||||||
|
|
||||||
/* is trivially constructible */
|
/* is trivially constructible */
|
||||||
|
@ -1006,39 +1006,39 @@ constexpr bool IsConvertible = detail::IsConvertibleBase<F, T>::value;
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename, uint>
|
template<typename, uint>
|
||||||
constexpr Size ExtentBase = 0;
|
constexpr size_t ExtentBase = 0;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr Size ExtentBase<T[], 0> = 0;
|
constexpr size_t ExtentBase<T[], 0> = 0;
|
||||||
|
|
||||||
template<typename T, uint I>
|
template<typename T, uint I>
|
||||||
constexpr Size ExtentBase<T[], I> = detail::ExtentBase<T, I - 1>;
|
constexpr size_t ExtentBase<T[], I> = detail::ExtentBase<T, I - 1>;
|
||||||
|
|
||||||
template<typename T, Size N>
|
template<typename T, size_t N>
|
||||||
constexpr Size ExtentBase<T[N], 0> = N;
|
constexpr size_t ExtentBase<T[N], 0> = N;
|
||||||
|
|
||||||
template<typename T, Size N, uint I>
|
template<typename T, size_t N, uint I>
|
||||||
constexpr Size ExtentBase<T[N], I> = detail::ExtentBase<T, I - 1>;
|
constexpr size_t ExtentBase<T[N], I> = detail::ExtentBase<T, I - 1>;
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
template<typename T, uint I = 0>
|
template<typename T, uint I = 0>
|
||||||
constexpr Size Extent = detail::ExtentBase<T, I>;
|
constexpr size_t Extent = detail::ExtentBase<T, I>;
|
||||||
|
|
||||||
/* rank */
|
/* rank */
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename>
|
template<typename>
|
||||||
constexpr Size RankBase = 0;
|
constexpr size_t RankBase = 0;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr Size RankBase<T[]> = detail::RankBase<T> + 1;
|
constexpr size_t RankBase<T[]> = detail::RankBase<T> + 1;
|
||||||
|
|
||||||
template<typename T, Size N>
|
template<typename T, size_t N>
|
||||||
constexpr Size RankBase<T[N]> = detail::RankBase<T> + 1;
|
constexpr size_t RankBase<T[N]> = detail::RankBase<T> + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr Size Rank = detail::RankBase<T>;
|
constexpr size_t Rank = detail::RankBase<T>;
|
||||||
|
|
||||||
/* remove const, volatile, cv */
|
/* remove const, volatile, cv */
|
||||||
|
|
||||||
|
@ -1205,7 +1205,7 @@ namespace detail {
|
||||||
struct RemoveExtentBase { using Type = T; };
|
struct RemoveExtentBase { using Type = T; };
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct RemoveExtentBase<T[]> { using Type = T; };
|
struct RemoveExtentBase<T[]> { using Type = T; };
|
||||||
template<typename T, Size N>
|
template<typename T, size_t N>
|
||||||
struct RemoveExtentBase<T[N]> { using Type = T; };
|
struct RemoveExtentBase<T[N]> { using Type = T; };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1223,7 +1223,7 @@ namespace detail {
|
||||||
using Type = RemoveAllExtentsBase<T>;
|
using Type = RemoveAllExtentsBase<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, Size N>
|
template<typename T, size_t N>
|
||||||
struct RemoveAllExtentsBase<T[N]> {
|
struct RemoveAllExtentsBase<T[N]> {
|
||||||
using Type = RemoveAllExtentsBase<T>;
|
using Type = RemoveAllExtentsBase<T>;
|
||||||
};
|
};
|
||||||
|
@ -1272,15 +1272,15 @@ namespace detail {
|
||||||
>
|
>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
template<typename T, Size N, bool = (N <= sizeof(typename T::First))>
|
template<typename T, size_t N, bool = (N <= sizeof(typename T::First))>
|
||||||
struct TypeFindFirst;
|
struct TypeFindFirst;
|
||||||
|
|
||||||
template<typename T, typename U, Size N>
|
template<typename T, typename U, size_t N>
|
||||||
struct TypeFindFirst<TypeList<T, U>, N, true> {
|
struct TypeFindFirst<TypeList<T, U>, N, true> {
|
||||||
using Type = T;
|
using Type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U, Size N>
|
template<typename T, typename U, size_t N>
|
||||||
struct TypeFindFirst<TypeList<T, U>, N, false> {
|
struct TypeFindFirst<TypeList<T, U>, N, false> {
|
||||||
using Type = typename TypeFindFirst<U, N>::Type;
|
using Type = typename TypeFindFirst<U, N>::Type;
|
||||||
};
|
};
|
||||||
|
@ -1605,7 +1605,7 @@ using CommonType = typename detail::CommonTypeBase<A...>::Type;
|
||||||
/* aligned storage */
|
/* aligned storage */
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
struct AlignedTest {
|
struct AlignedTest {
|
||||||
union Type {
|
union Type {
|
||||||
byte data[N];
|
byte data[N];
|
||||||
|
@ -1613,7 +1613,7 @@ namespace detail {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template<Size N, Size A>
|
template<size_t N, size_t A>
|
||||||
struct AlignedStorageBase {
|
struct AlignedStorageBase {
|
||||||
struct Type {
|
struct Type {
|
||||||
alignas(A) byte data[N];
|
alignas(A) byte data[N];
|
||||||
|
@ -1621,7 +1621,7 @@ namespace detail {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<Size N, Size A
|
template<size_t N, size_t A
|
||||||
= alignof(typename detail::AlignedTest<N>::Type)
|
= alignof(typename detail::AlignedTest<N>::Type)
|
||||||
>
|
>
|
||||||
using AlignedStorage = typename detail::AlignedStorageBase<N, A>::Type;
|
using AlignedStorage = typename detail::AlignedStorageBase<N, A>::Type;
|
||||||
|
@ -1629,20 +1629,20 @@ using AlignedStorage = typename detail::AlignedStorageBase<N, A>::Type;
|
||||||
/* aligned union */
|
/* aligned union */
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<Size ...N>
|
template<size_t ...N>
|
||||||
constexpr Size AlignMax = 0;
|
constexpr size_t AlignMax = 0;
|
||||||
template<Size N>
|
template<size_t N>
|
||||||
constexpr Size AlignMax<N> = N;
|
constexpr size_t AlignMax<N> = N;
|
||||||
|
|
||||||
template<Size N1, Size N2>
|
template<size_t N1, size_t N2>
|
||||||
constexpr Size AlignMax<N1, N2> = (N1 > N2) ? N1 : N2;
|
constexpr size_t AlignMax<N1, N2> = (N1 > N2) ? N1 : N2;
|
||||||
|
|
||||||
template<Size N1, Size N2, Size ...N>
|
template<size_t N1, size_t N2, size_t ...N>
|
||||||
constexpr Size AlignMax<N1, N2, N...> = AlignMax<AlignMax<N1, N2>, N...>;
|
constexpr size_t AlignMax<N1, N2, N...> = AlignMax<AlignMax<N1, N2>, N...>;
|
||||||
|
|
||||||
template<Size N, typename ...T>
|
template<size_t N, typename ...T>
|
||||||
struct AlignedUnionBase {
|
struct AlignedUnionBase {
|
||||||
static constexpr Size alignment_value = AlignMax<alignof(T)...>;
|
static constexpr size_t alignment_value = AlignMax<alignof(T)...>;
|
||||||
|
|
||||||
struct Type {
|
struct Type {
|
||||||
alignas(alignment_value) byte data[AlignMax<N, sizeof(T)...>];
|
alignas(alignment_value) byte data[AlignMax<N, sizeof(T)...>];
|
||||||
|
@ -1650,7 +1650,7 @@ namespace detail {
|
||||||
};
|
};
|
||||||
} /* namespace detail */
|
} /* namespace detail */
|
||||||
|
|
||||||
template<Size N, typename ...T>
|
template<size_t N, typename ...T>
|
||||||
using AlignedUnion = typename detail::AlignedUnionBase<N, T...>::Type;
|
using AlignedUnion = typename detail::AlignedUnionBase<N, T...>::Type;
|
||||||
|
|
||||||
/* underlying type */
|
/* underlying type */
|
||||||
|
|
|
@ -55,11 +55,6 @@ using MaxAlign = ::max_align_t;
|
||||||
using MaxAlign = long double;
|
using MaxAlign = long double;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* stddef */
|
|
||||||
|
|
||||||
using Ptrdiff = ptrdiff_t;
|
|
||||||
using Size = size_t;
|
|
||||||
|
|
||||||
/* stdint */
|
/* stdint */
|
||||||
|
|
||||||
using Intmax = intmax_t;
|
using Intmax = intmax_t;
|
||||||
|
|
|
@ -20,29 +20,29 @@ namespace detail {
|
||||||
bool = IsSame<RemoveCv<T>, RemoveCv<U>>,
|
bool = IsSame<RemoveCv<T>, RemoveCv<U>>,
|
||||||
bool = IsEmpty<T>, bool = IsEmpty<U>
|
bool = IsEmpty<T>, bool = IsEmpty<U>
|
||||||
>
|
>
|
||||||
constexpr Size CompressedPairSwitch = detail::Undefined<T>();
|
constexpr size_t CompressedPairSwitch = detail::Undefined<T>();
|
||||||
|
|
||||||
/* neither empty */
|
/* neither empty */
|
||||||
template<typename T, typename U, bool Same>
|
template<typename T, typename U, bool Same>
|
||||||
constexpr Size CompressedPairSwitch<T, U, Same, false, false> = 0;
|
constexpr size_t CompressedPairSwitch<T, U, Same, false, false> = 0;
|
||||||
|
|
||||||
/* first empty */
|
/* first empty */
|
||||||
template<typename T, typename U, bool Same>
|
template<typename T, typename U, bool Same>
|
||||||
constexpr Size CompressedPairSwitch<T, U, Same, true, false> = 1;
|
constexpr size_t CompressedPairSwitch<T, U, Same, true, false> = 1;
|
||||||
|
|
||||||
/* second empty */
|
/* second empty */
|
||||||
template<typename T, typename U, bool Same>
|
template<typename T, typename U, bool Same>
|
||||||
constexpr Size CompressedPairSwitch<T, U, Same, false, true> = 2;
|
constexpr size_t CompressedPairSwitch<T, U, Same, false, true> = 2;
|
||||||
|
|
||||||
/* both empty, not the same */
|
/* both empty, not the same */
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
constexpr Size CompressedPairSwitch<T, U, false, true, true> = 3;
|
constexpr size_t CompressedPairSwitch<T, U, false, true, true> = 3;
|
||||||
|
|
||||||
/* both empty and same */
|
/* both empty and same */
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
constexpr Size CompressedPairSwitch<T, U, true, true, true> = 1;
|
constexpr size_t CompressedPairSwitch<T, U, true, true, true> = 1;
|
||||||
|
|
||||||
template<typename T, typename U, Size = CompressedPairSwitch<T, U>>
|
template<typename T, typename U, size_t = CompressedPairSwitch<T, U>>
|
||||||
struct CompressedPairBase;
|
struct CompressedPairBase;
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
|
@ -55,7 +55,7 @@ namespace detail {
|
||||||
p_first(std::forward<TT>(a)), p_second(std::forward<UU>(b))
|
p_first(std::forward<TT>(a)), p_second(std::forward<UU>(b))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename ...A1, typename ...A2, Size ...I1, Size ...I2>
|
template<typename ...A1, typename ...A2, size_t ...I1, size_t ...I2>
|
||||||
CompressedPairBase(
|
CompressedPairBase(
|
||||||
std::piecewise_construct_t,
|
std::piecewise_construct_t,
|
||||||
std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
||||||
|
@ -83,7 +83,7 @@ namespace detail {
|
||||||
T(std::forward<TT>(a)), p_second(std::forward<UU>(b))
|
T(std::forward<TT>(a)), p_second(std::forward<UU>(b))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename ...A1, typename ...A2, Size ...I1, Size ...I2>
|
template<typename ...A1, typename ...A2, size_t ...I1, size_t ...I2>
|
||||||
CompressedPairBase(
|
CompressedPairBase(
|
||||||
std::piecewise_construct_t,
|
std::piecewise_construct_t,
|
||||||
std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
||||||
|
@ -110,7 +110,7 @@ namespace detail {
|
||||||
U(std::forward<UU>(b)), p_first(std::forward<TT>(a))
|
U(std::forward<UU>(b)), p_first(std::forward<TT>(a))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename ...A1, typename ...A2, Size ...I1, Size ...I2>
|
template<typename ...A1, typename ...A2, size_t ...I1, size_t ...I2>
|
||||||
CompressedPairBase(
|
CompressedPairBase(
|
||||||
std::piecewise_construct_t,
|
std::piecewise_construct_t,
|
||||||
std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
||||||
|
@ -135,7 +135,7 @@ namespace detail {
|
||||||
T(std::forward<TT>(a)), U(std::forward<UU>(b))
|
T(std::forward<TT>(a)), U(std::forward<UU>(b))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename ...A1, typename ...A2, Size ...I1, Size ...I2>
|
template<typename ...A1, typename ...A2, size_t ...I1, size_t ...I2>
|
||||||
CompressedPairBase(
|
CompressedPairBase(
|
||||||
std::piecewise_construct_t,
|
std::piecewise_construct_t,
|
||||||
std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
||||||
|
@ -184,7 +184,7 @@ namespace detail {
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
template<typename ...A1, typename ...A2, Size ...I1, Size ...I2>
|
template<typename ...A1, typename ...A2, size_t ...I1, size_t ...I2>
|
||||||
CompressedPairBase<T, U, 0>::CompressedPairBase(
|
CompressedPairBase<T, U, 0>::CompressedPairBase(
|
||||||
std::piecewise_construct_t, std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
std::piecewise_construct_t, std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
||||||
std::index_sequence<I1...>, std::index_sequence<I2...>
|
std::index_sequence<I1...>, std::index_sequence<I2...>
|
||||||
|
@ -194,7 +194,7 @@ namespace detail {
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
template<typename ...A1, typename ...A2, Size ...I1, Size ...I2>
|
template<typename ...A1, typename ...A2, size_t ...I1, size_t ...I2>
|
||||||
CompressedPairBase<T, U, 1>::CompressedPairBase(
|
CompressedPairBase<T, U, 1>::CompressedPairBase(
|
||||||
std::piecewise_construct_t, std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
std::piecewise_construct_t, std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
||||||
std::index_sequence<I1...>, std::index_sequence<I2...>
|
std::index_sequence<I1...>, std::index_sequence<I2...>
|
||||||
|
@ -204,7 +204,7 @@ namespace detail {
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
template<typename ...A1, typename ...A2, Size ...I1, Size ...I2>
|
template<typename ...A1, typename ...A2, size_t ...I1, size_t ...I2>
|
||||||
CompressedPairBase<T, U, 2>::CompressedPairBase(
|
CompressedPairBase<T, U, 2>::CompressedPairBase(
|
||||||
std::piecewise_construct_t, std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
std::piecewise_construct_t, std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
||||||
std::index_sequence<I1...>, std::index_sequence<I2...>
|
std::index_sequence<I1...>, std::index_sequence<I2...>
|
||||||
|
@ -214,7 +214,7 @@ namespace detail {
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
template<typename ...A1, typename ...A2, Size ...I1, Size ...I2>
|
template<typename ...A1, typename ...A2, size_t ...I1, size_t ...I2>
|
||||||
CompressedPairBase<T, U, 3>::CompressedPairBase(
|
CompressedPairBase<T, U, 3>::CompressedPairBase(
|
||||||
std::piecewise_construct_t, std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
std::piecewise_construct_t, std::tuple<A1...> &fa, std::tuple<A2...> &sa,
|
||||||
std::index_sequence<I1...>, std::index_sequence<I2...>
|
std::index_sequence<I1...>, std::index_sequence<I2...>
|
||||||
|
|
|
@ -22,8 +22,8 @@ struct Vec2 {
|
||||||
Vec2(T v): x(v), y(v) {}
|
Vec2(T v): x(v), y(v) {}
|
||||||
Vec2(T x, T y): x(x), y(y) {}
|
Vec2(T x, T y): x(x), y(y) {}
|
||||||
|
|
||||||
T &operator[](Size idx) { return value[idx]; }
|
T &operator[](size_t idx) { return value[idx]; }
|
||||||
T operator[](Size idx) const { return value[idx]; }
|
T operator[](size_t idx) const { return value[idx]; }
|
||||||
|
|
||||||
Vec2 &add(T v) {
|
Vec2 &add(T v) {
|
||||||
x += v; y += v;
|
x += v; y += v;
|
||||||
|
@ -148,8 +148,8 @@ struct Vec3 {
|
||||||
Vec3(T v): x(v), y(v), z(v) {}
|
Vec3(T v): x(v), y(v), z(v) {}
|
||||||
Vec3(T x, T y, T z): x(x), y(y), z(z) {}
|
Vec3(T x, T y, T z): x(x), y(y), z(z) {}
|
||||||
|
|
||||||
T &operator[](Size idx) { return value[idx]; }
|
T &operator[](size_t idx) { return value[idx]; }
|
||||||
T operator[](Size idx) const { return value[idx]; }
|
T operator[](size_t idx) const { return value[idx]; }
|
||||||
|
|
||||||
Vec3 &add(T v) {
|
Vec3 &add(T v) {
|
||||||
x += v; y += v; z += v;
|
x += v; y += v; z += v;
|
||||||
|
@ -274,8 +274,8 @@ struct Vec4 {
|
||||||
Vec4(T v): x(v), y(v), z(v), w(v) {}
|
Vec4(T v): x(v), y(v), z(v), w(v) {}
|
||||||
Vec4(T x, T y, T z, T w): x(x), y(y), z(z), w(w) {}
|
Vec4(T x, T y, T z, T w): x(x), y(y), z(z), w(w) {}
|
||||||
|
|
||||||
T &operator[](Size idx) { return value[idx]; }
|
T &operator[](size_t idx) { return value[idx]; }
|
||||||
T operator[](Size idx) const { return value[idx]; }
|
T operator[](size_t idx) const { return value[idx]; }
|
||||||
|
|
||||||
Vec4 &add(T v) {
|
Vec4 &add(T v) {
|
||||||
x += v; y += v; z += v; w += v;
|
x += v; y += v; z += v; w += v;
|
||||||
|
|
Loading…
Reference in New Issue