diff --git a/include/chaiscript/dispatchkit/bootstrap_stl.hpp b/include/chaiscript/dispatchkit/bootstrap_stl.hpp index 82321021..20099239 100644 --- a/include/chaiscript/dispatchkit/bootstrap_stl.hpp +++ b/include/chaiscript/dispatchkit/bootstrap_stl.hpp @@ -181,11 +181,14 @@ namespace detail { ModulePtr random_access_container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module())) { typedef typename ContainerType::reference(ContainerType::*indexoper)(size_t); + typedef typename ContainerType::const_reference(ContainerType::*constindexoper)(size_t) const; //In the interest of runtime safety for the m, we prefer the at() method for [] access, //to throw an exception in an out of bounds condition. m->add( fun(boost::function(boost::mem_fn(static_cast(&ContainerType::at)))), "[]"); + m->add( + fun(boost::function(boost::mem_fn(static_cast(&ContainerType::at)))), "[]"); return m; } diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index ec1b467b..95b99ea0 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -372,29 +372,20 @@ namespace chaiscript * Evaluates (and generates) an inline array initialization */ Boxed_Value Inline_Array_AST_Node::eval(Dispatch_Engine &ss) { - try { - Boxed_Value retval = ss.call_function("Vector"); - if (this->children.size() > 0) { - for (size_t i = 0; i < this->children[0]->children.size(); ++i) { - try { - ss.call_function("push_back", retval, this->children[0]->children[i]->eval(ss)); - } - catch (const dispatch_error &) { - throw Eval_Error("Can not find appropriate 'push_back'"); - } - catch(Eval_Error &ee) { - ee.call_stack.push_back(this->children[0]->children[i]); - throw; - } + std::vector vec; + if (this->children.size() > 0) { + for (size_t i = 0; i < this->children[0]->children.size(); ++i) { + try { + vec.push_back(this->children[0]->children[i]->eval(ss)); + } + catch(Eval_Error &ee) { + ee.call_stack.push_back(this->children[0]->children[i]); + throw; } } - - return retval; - } - catch (const dispatch_error &) { - throw Eval_Error("Can not find appropriate 'Vector()'"); } + return const_var(vec); } /**