From 0520bb178c2f26d92ccaba9c0cd554c1260be6f4 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 20 May 2018 20:36:33 -0600 Subject: [PATCH] Fix capture error --- include/chaiscript/dispatchkit/bootstrap.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index 1cddf81e..671a723a 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -23,10 +23,10 @@ namespace chaiscript void array(const std::string &type, Module& m) { typedef typename std::remove_extent::type ReturnType; - constexpr auto extent = std::extent::value; m.add(user_type(), type); m.add(fun( [](T& t, size_t index)->ReturnType &{ + constexpr auto extent = std::extent::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::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::value; return extent; }), "size"); }