mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-06 16:57:04 +08:00
Fix capture error
This commit is contained in:
parent
c14d9dfb6e
commit
0520bb178c
@ -23,10 +23,10 @@ namespace chaiscript
|
||||
void array(const std::string &type, Module& m)
|
||||
{
|
||||
typedef typename std::remove_extent<T>::type ReturnType;
|
||||
constexpr auto extent = std::extent<T>::value;
|
||||
m.add(user_type<T>(), type);
|
||||
m.add(fun(
|
||||
[](T& t, size_t index)->ReturnType &{
|
||||
constexpr auto extent = std::extent<T>::value;
|
||||
if (extent > 0 && index >= extent) {
|
||||
throw std::range_error("Array index out of range. Received: " + std::to_string(index) + " expected < " + std::to_string(extent));
|
||||
} else {
|
||||
@ -38,6 +38,7 @@ namespace chaiscript
|
||||
|
||||
m.add(fun(
|
||||
[](const T &t, size_t index)->const ReturnType &{
|
||||
constexpr auto extent = std::extent<T>::value;
|
||||
if (extent > 0 && index >= extent) {
|
||||
throw std::range_error("Array index out of range. Received: " + std::to_string(index) + " expected < " + std::to_string(extent));
|
||||
} else {
|
||||
@ -49,6 +50,7 @@ namespace chaiscript
|
||||
|
||||
m.add(fun(
|
||||
[](const T &) {
|
||||
constexpr auto extent = std::extent<T>::value;
|
||||
return extent;
|
||||
}), "size");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user