diff --git a/cheatsheet.md b/cheatsheet.md index 25b8469..9b51f2a 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -107,8 +107,9 @@ chai.add(chaiscript::var(std::ref(somevar), "somevar"); // by reference, shared auto shareddouble = std::make_shared(4.3); chai.add(chaiscript::var(shareddouble), "shareddouble"); // by shared_ptr, shared between c++ and chai chai.add(chaiscript::const_var(somevar), "somevar"); // copied in and made const -chai.add_global_const(chaiscript::const_var(somevar), "somevar"); // global const. Throws if value is non-const -chai.add_global(chaiscript::var(somevar), "somevar"); // global non-const +chai.add_global_const(chaiscript::const_var(somevar), "somevar"); // global const. Throws if value is non-const, throws if object exists +chai.add_global(chaiscript::var(somevar), "somevar"); // global non-const, throws if object exists +chai.set_global(chaiscript::var(somevar), "somevar"); // global non-const, overwrites existing object ``` # Using STL ChaiScript recognize many types from STL, but you have to add specific instantiation yourself. diff --git a/include/chaiscript/chaiscript_stdlib.hpp b/include/chaiscript/chaiscript_stdlib.hpp index 4b38f2c..84797b7 100644 --- a/include/chaiscript/chaiscript_stdlib.hpp +++ b/include/chaiscript/chaiscript_stdlib.hpp @@ -49,7 +49,13 @@ namespace chaiscript #ifndef CHAISCRIPT_NO_THREADS lib->add(standard_library::future_type>("future")); +#ifdef CHAISCRIPT_MSVC + /// this is to work around an issue that seems to only come up on single CPU hosts on MSVC 2015 Update 1 + /// \todo reevaluate this later + lib->add(chaiscript::fun([](const std::function &t_func){ return std::async(std::thread::hardware_concurrency() <= 1 ? std::launch::deferred : std::launch::async, t_func);}), "async"); +#else lib->add(chaiscript::fun([](const std::function &t_func){ return std::async(std::launch::async, t_func);}), "async"); +#endif #endif lib->add(json_wrap::library());