From d2d262afbd9576efc7cc768f442c6fe4661e1a23 Mon Sep 17 00:00:00 2001 From: q66 Date: Sun, 29 Jan 2017 19:30:54 +0100 Subject: [PATCH] note about std::function --- include/cubescript/cubescript_conf.hh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/cubescript/cubescript_conf.hh b/include/cubescript/cubescript_conf.hh index ac6532bd..923595cc 100644 --- a/include/cubescript/cubescript_conf.hh +++ b/include/cubescript/cubescript_conf.hh @@ -25,12 +25,20 @@ namespace cscript { using CsInt = int; using CsFloat = float; + /* probably don't want to change these, but if you use a custom allocation + * function for your state, keep in mind potential heap allocations in + * these are not handled by it (as std::function has no allocator support) + * + * normally std::function is optimized not to do allocations for small + * objects, so as long as you don't pass a lambda that captures by copy + * or move or something similar, you should be fine - but if you really + * need to make sure, override this with your own type + */ using CsVarCb = std::function; using CsCommandCb = std::function; using CsHookCb = std::function; using CsAllocCb = void *(*)(void *, void *, size_t, size_t); - constexpr auto const IntFormat = "%d"; constexpr auto const FloatFormat = "%.7g"; constexpr auto const RoundFloatFormat = "%.1f";