Ver Fonte

Add Vector::Emplace. Fix HashMap::Populate signature. Disable MSVC warnings.

Eugene Kozlov há 7 anos atrás
pai
commit
b75e1015bd

+ 1 - 1
CMake/Modules/UrhoCommon.cmake

@@ -539,7 +539,7 @@ if (APPLE)
 endif ()
 if (MSVC)
     # VS-specific setup
-    add_definitions (-D_CRT_SECURE_NO_WARNINGS)
+    add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
     if (URHO3D_STATIC_RUNTIME)
         set (RELEASE_RUNTIME /MT)
         set (DEBUG_RUNTIME /MTd)

+ 1 - 1
Source/Urho3D/Container/HashMap.h

@@ -359,7 +359,7 @@ public:
         return *this;
     };
     /// Populate the map using variadic template.
-    template <typename... Args> HashMap& Populate(const T& key, const U& value, Args... args)
+    template <typename... Args> HashMap& Populate(const T& key, const U& value, const Args&... args)
     {
         this->operator [](key) = value;
         return Populate(args...);

+ 8 - 0
Source/Urho3D/Container/Vector.h

@@ -213,6 +213,14 @@ public:
         return Buffer()[index];
     }
 
+    /// Create an element at the end.
+    template <class... Args> T& Emplace(Args&&... args)
+    {
+        T value(std::forward(args)...);
+        Push(std::move(value));
+        return Back();
+    }
+
     /// Add an element at the end.
 #ifndef COVERITY_SCAN_MODEL
     void Push(const T& value)