浏览代码

Fix warning on MSVC

Michael Ragazzon 5 年之前
父节点
当前提交
4506c911f4
共有 1 个文件被更改,包括 8 次插入3 次删除
  1. 8 3
      Source/Core/Memory.cpp

+ 8 - 3
Source/Core/Memory.cpp

@@ -27,6 +27,7 @@
  */
 
 #include "Memory.h"
+#include <memory>
 #include <stdlib.h>
 #include <stdint.h>
 
@@ -35,11 +36,14 @@ namespace Core {
 
 namespace Detail {
 
-// std::align replacement to support compilers missing this feature.
-// From https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57350
-//
 inline void* rmlui_align(size_t alignment, size_t size, void*& ptr, size_t& space)
 {
+#if defined(_MSC_VER)
+    return std::align(alignment, size, ptr, space);
+#else
+	// std::align replacement to support compilers missing this feature.
+	// From https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57350
+
     uintptr_t pn = reinterpret_cast<uintptr_t>(ptr);
     uintptr_t aligned = (pn + alignment - 1) & -alignment;
     size_t padding = aligned - pn;
@@ -47,6 +51,7 @@ inline void* rmlui_align(size_t alignment, size_t size, void*& ptr, size_t& spac
         return nullptr;
     space -= padding;
     return ptr = reinterpret_cast<void*>(aligned);
+#endif
 }
 
 BasicStackAllocator::BasicStackAllocator(size_t N) : N(N), data((byte*)malloc(N)), p(data)