Avoid warnings
This commit is contained in:
parent
fcb4f3bc63
commit
bdd399af16
|
|
@ -44,7 +44,7 @@ public:
|
|||
inline vector& operator=(vector&& src) noexcept { swap(src); return *this; }
|
||||
inline vector& operator=(initializer_list list) { if (list.size()) { assign(list.begin(), list.end()); } else clear(); return (*this); }
|
||||
|
||||
inline vector& assign(size_type count, const _Ty& val) { if (count > 0) { resize(count); manager::copy(begin(), count, val); } else clear(); return (*this); }
|
||||
inline vector& assign(size_type count, const _Ty& val) { if (count > 0) { resize(count); manager::fill_n(begin(), count, val); } else clear(); return (*this); }
|
||||
inline vector& assign(const vector& src) { return operator=(src); }
|
||||
inline vector& assign(initializer_list list) { return operator=(list); }
|
||||
|
||||
|
|
|
|||
|
|
@ -27,19 +27,56 @@ struct vector_memory_manager<_Ty, _Alloc, true>
|
|||
using size_type = size_t;
|
||||
using allocator_type = typename _Alloc;
|
||||
|
||||
static void copy(value_type* const dest, const size_type count, const value_type& val) { for (size_type i = 0; i < count; ++i) std::memcpy(&dest[i], &val, sizeof(value_type)); }
|
||||
static void copy_n(value_type* const dest, const value_type* src, const size_type count) { if (src == dest) return; std::memcpy(dest, src, count * sizeof(value_type)); }
|
||||
static void move(value_type* const dest, const value_type* src, const size_type count) { if (src == dest) return; std::memmove(dest, src, count * sizeof(value_type)); }
|
||||
static void fill_n(value_type* const dest, ptrdiff_t count, const value_type& val)
|
||||
{
|
||||
for (ptrdiff_t i = 0; i < count; ++i)
|
||||
std::memcpy(std::addressof(dest[i]), std::addressof(val), sizeof(value_type));
|
||||
}
|
||||
|
||||
static void construct(value_type* const ptr, const size_type count, const value_type& val) { copy(ptr, count, val); }
|
||||
static void construct_n(value_type* const ptr, const value_type* src, const size_type count) { copy_n(ptr, src, count); }
|
||||
static void destroy(value_type* const ptr, const size_type count) { }
|
||||
static void copy_n(value_type* const dest, const value_type* src, ptrdiff_t count)
|
||||
{
|
||||
if (src == dest)
|
||||
return;
|
||||
std::memcpy(dest, src, count * sizeof(value_type));
|
||||
}
|
||||
|
||||
static value_type* allocate(const size_type count) { return get_allocator().allocate(count); }
|
||||
static void deallocate(value_type*& ptr, const size_type count) { if (ptr) { get_allocator().deallocate(ptr, count); ptr = nullptr; } }
|
||||
static void move(value_type* const dest, const value_type* src, ptrdiff_t count)
|
||||
{
|
||||
if (src == dest)
|
||||
return;
|
||||
std::memmove(dest, src, count * sizeof(value_type));
|
||||
}
|
||||
|
||||
static void construct(value_type* const ptr, ptrdiff_t count, const value_type& val)
|
||||
{
|
||||
fill_n(ptr, count, val);
|
||||
}
|
||||
|
||||
static void construct_n(value_type* const ptr, const value_type* src, ptrdiff_t count)
|
||||
{
|
||||
copy_n(ptr, src, count);
|
||||
}
|
||||
|
||||
static void destroy(value_type* const ptr, ptrdiff_t count)
|
||||
{
|
||||
}
|
||||
|
||||
static value_type* allocate(ptrdiff_t count)
|
||||
{
|
||||
return get_allocator().allocate(count);
|
||||
}
|
||||
|
||||
static void deallocate(value_type*& ptr, ptrdiff_t count)
|
||||
{
|
||||
if (ptr)
|
||||
{
|
||||
get_allocator().deallocate(ptr, count);
|
||||
ptr = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static allocator_type& get_allocator()
|
||||
static inline allocator_type& get_allocator()
|
||||
{
|
||||
static allocator_type allocator_;
|
||||
return allocator_;
|
||||
|
|
@ -56,19 +93,75 @@ struct vector_memory_manager<_Ty, _Alloc, false>
|
|||
using size_type = size_t;
|
||||
using allocator_type = typename _Alloc;
|
||||
|
||||
static void copy(value_type* const dest, const size_type count, const value_type& val) { std::fill_n(dest, count, val); }
|
||||
static void copy_n(value_type* const dest, const value_type* src, const size_type count) { if (src == dest) return; std::copy_n(src, count, dest); }
|
||||
static void move(value_type* const dest, const value_type* src, const size_type count) { if (src == dest) return; if (dest > src && dest < src + count) std::copy_backward(src, src + count, dest); else copy_n(dest, src, count); }
|
||||
static void fill_n(value_type* const dest, ptrdiff_t count, const value_type& val)
|
||||
{
|
||||
// Avoid warning C4996
|
||||
// std::fill_n(dest, count, val);
|
||||
for (ptrdiff_t i = 0; i < count; ++i)
|
||||
dest[i] = val;
|
||||
}
|
||||
|
||||
static void construct(value_type* const ptr, const size_type count, const value_type& val) { for (size_type i = 0; i < count; ++i) get_allocator().construct(std::addressof(ptr[i]), val); }
|
||||
static void construct_n(value_type* const ptr, const value_type* src, const size_type count) { for (size_type i = 0; i < count; ++i) get_allocator().construct(std::addressof(ptr[i]), src[i]); }
|
||||
static void destroy(value_type* const ptr, const size_type count) { for (size_type i = 0; i < count; ++i) get_allocator().destroy(std::addressof(ptr[i])); }
|
||||
static void copy_n(value_type* const dest, const value_type* src, ptrdiff_t count)
|
||||
{
|
||||
if (src == dest)
|
||||
return;
|
||||
|
||||
static value_type* allocate(const size_type count) { return get_allocator().allocate(count); }
|
||||
static void deallocate(value_type*& ptr, const size_type count) { if (ptr) { get_allocator().deallocate(ptr, count); ptr = nullptr; } }
|
||||
// Avoid warning C4996
|
||||
// std::copy_n(src, count, dest);
|
||||
for (ptrdiff_t i = 0; i < count; ++i)
|
||||
dest[i] = src[i];
|
||||
}
|
||||
|
||||
static void move(value_type* const dest, const value_type* src, ptrdiff_t count)
|
||||
{
|
||||
if (src == dest)
|
||||
return;
|
||||
|
||||
if (dest > src && dest < src + count)
|
||||
{
|
||||
// Avoid warning C4996
|
||||
// std::copy_backward(src, src + count, dest);
|
||||
for (ptrdiff_t i = 0; i < count; ++i)
|
||||
dest[count - i - 1] = src[count - i - 1];
|
||||
}
|
||||
else
|
||||
copy_n(dest, src, count);
|
||||
}
|
||||
|
||||
static void construct(value_type* const ptr, ptrdiff_t count, const value_type& val)
|
||||
{
|
||||
for (ptrdiff_t i = 0; i < count; ++i)
|
||||
get_allocator().construct(std::addressof(ptr[i]), val);
|
||||
}
|
||||
|
||||
static void construct_n(value_type* const ptr, const value_type* src, ptrdiff_t count)
|
||||
{
|
||||
for (ptrdiff_t i = 0; i < count; ++i)
|
||||
get_allocator().construct(std::addressof(ptr[i]), src[i]);
|
||||
}
|
||||
|
||||
static void destroy(value_type* const ptr, ptrdiff_t count)
|
||||
{
|
||||
for (ptrdiff_t i = 0; i < count; ++i)
|
||||
get_allocator().destroy(std::addressof(ptr[i]));
|
||||
}
|
||||
|
||||
static value_type* allocate(ptrdiff_t count)
|
||||
{
|
||||
return get_allocator().allocate(count);
|
||||
}
|
||||
|
||||
static void deallocate(value_type*& ptr, ptrdiff_t count)
|
||||
{
|
||||
if (ptr)
|
||||
{
|
||||
get_allocator().deallocate(ptr, count);
|
||||
ptr = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static allocator_type& get_allocator()
|
||||
static inline allocator_type& get_allocator()
|
||||
{
|
||||
static allocator_type allocator_;
|
||||
return allocator_;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@
|
|||
#include <kiwano/renderer/win32/D3D11DeviceResources.h>
|
||||
#include <kiwano/core/Logger.h>
|
||||
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4800)
|
||||
#include <versionhelpers.h> // IsWindows10OrGreater
|
||||
#pragma warning (pop)
|
||||
|
||||
#pragma comment(lib, "d3d11.lib")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue