diff --git a/lib/base/array.hpp b/lib/base/array.hpp index f28d66b4b..b224fba31 100644 --- a/lib/base/array.hpp +++ b/lib/base/array.hpp @@ -21,6 +21,7 @@ #define ARRAY_H #include "base/i2-base.hpp" +#include "base/objectlock.hpp" #include "base/value.hpp" #include #include @@ -100,6 +101,15 @@ public: static Object::Ptr GetPrototype(void); + template + static Array::Ptr FromVector(const std::vector& v) + { + Array::Ptr result = new Array(); + ObjectLock olock(result); + std::copy(v.begin(), v.end(), std::back_inserter(result->m_Data)); + return result; + } + private: std::vector m_Data; /**< The data for the array. */ };