From 28e09660d30fc17969916673fdc8475ceeedbeb2 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Fri, 7 Mar 2014 15:25:11 +0100 Subject: added constructor to Php::Array class to accept std::vector and std::map --- include/array.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'include/array.h') diff --git a/include/array.h b/include/array.h index 94d2824..3b92826 100644 --- a/include/array.h +++ b/include/array.h @@ -22,7 +22,7 @@ public: /** * Constructor */ - Array() : Value() { setType(Type::Array); } + Array() : Value(Type::Array) {} /** * Copy constructor from a value object @@ -43,6 +43,20 @@ public: // type must be valid if (value.type() != Type::Array) throw Php::Exception("Moving a non-array to an array variable"); } + + /** + * Constructors from a vector (this will create an array) + * @param value + */ + template + Array(const std::vector &input) : Value(input) {} + + /** + * Constructor from a map (this will create an associative array) + * @param value + */ + template + Array(const std::map &value) : Value(value) {} /** * Destructor -- cgit v1.2.3