Switching .at and [], added out of bounds exception
This commit is contained in:
parent
4d56cffb26
commit
da60cad358
@ -16,9 +16,9 @@ void bootstrap_random_access_container(BoxedCPP_System &system, const std::strin
|
||||
typedef typename ContainerType::reference(ContainerType::*indexoper)(size_t);
|
||||
|
||||
system.register_function(
|
||||
boost::function<typename ContainerType::reference (ContainerType *, int)>(indexoper(&ContainerType::operator[])), "[]");
|
||||
boost::function<typename ContainerType::reference (ContainerType *, int)>(indexoper(&ContainerType::at)), "[]");
|
||||
system.register_function(
|
||||
boost::function<typename ContainerType::reference (ContainerType *, int)>(indexoper(&ContainerType::at)), "at");
|
||||
boost::function<typename ContainerType::reference (ContainerType *, int)>(indexoper(&ContainerType::operator[])), "at");
|
||||
}
|
||||
|
||||
template<typename Assignable>
|
||||
|
@ -131,6 +131,9 @@ Boxed_Value eval_token(Eval_System &ss, TokenPtr node) {
|
||||
try {
|
||||
retval = dispatch(ss.get_function("[]"), plb);
|
||||
}
|
||||
catch(std::out_of_range &oor) {
|
||||
throw EvalError("Out of bounds exception", node);
|
||||
}
|
||||
catch(std::exception &e){
|
||||
throw EvalError("Can not find appropriate array lookup '[]'", node->children[i]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user