forked from OctaForge/libostd
initializer list fixes
parent
ffbb7da63a
commit
f0380a2aaf
|
@ -22,16 +22,18 @@ namespace std {
|
|||
typedef size_t SizeType;
|
||||
typedef ptrdiff_t DiffType;
|
||||
typedef T ValType;
|
||||
typedef T &RefType;
|
||||
typedef const T &RefType;
|
||||
typedef const T &ConstRefType;
|
||||
typedef T *PtrType;
|
||||
typedef const T *PtrType;
|
||||
typedef const T *ConstPtrType;
|
||||
typedef octa::PointerRange<const T> RangeType;
|
||||
typedef octa::PointerRange<const T> ConstRangeType;
|
||||
|
||||
initializer_list(): p_buf(nullptr), p_len(0) {}
|
||||
|
||||
size_t length() const { return p_len; }
|
||||
|
||||
const T *get() const { return p_buf; }
|
||||
const T *data() const { return p_buf; }
|
||||
|
||||
octa::PointerRange<const T> each() {
|
||||
return octa::PointerRange<const T>(p_buf, p_len);
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace octa {
|
|||
|
||||
Vector(InitializerList<T> v): Vector() {
|
||||
size_t len = v.length();
|
||||
const T *ptr = v.get();
|
||||
const T *ptr = v.data();
|
||||
reserve(len);
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
new (&p_buf[i]) T(ptr[i]);
|
||||
|
@ -146,9 +146,9 @@ namespace octa {
|
|||
size_t ilen = il.length();
|
||||
reserve(ilen);
|
||||
if (octa::IsPod<T>()) {
|
||||
memcpy(p_buf, il.get(), ilen);
|
||||
memcpy(p_buf, il.data(), ilen);
|
||||
} else {
|
||||
T *buf = p_buf, *ibuf = il.get(), *last = il.get() + ilen;
|
||||
T *buf = p_buf, *ibuf = il.data(), *last = il.data() + ilen;
|
||||
while (ibuf != last) {
|
||||
new (buf++) T(*ibuf++);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue