From 45baf6f8e9388b373913931de35250696758660e Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 2 May 2015 13:08:23 -0600 Subject: [PATCH] Global const values for booleans - Reduces number of Boxed_Value constructions greatly --- include/chaiscript/dispatchkit/boxed_value.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/chaiscript/dispatchkit/boxed_value.hpp b/include/chaiscript/dispatchkit/boxed_value.hpp index 08a115c3..87d10545 100644 --- a/include/chaiscript/dispatchkit/boxed_value.hpp +++ b/include/chaiscript/dispatchkit/boxed_value.hpp @@ -409,6 +409,16 @@ namespace chaiscript return detail::const_var_impl(t); } + inline Boxed_Value const_var(bool b) { + static auto t = detail::const_var_impl(true); + static auto f = detail::const_var_impl(false); + + if (b) { + return t; + } else { + return f; + } + } }