From af0097fb7f139b171f83bca1eb4f67ffd5576bac Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 12 Dec 2013 19:48:26 -0500 Subject: [PATCH] Add support for setting functions with operator[] --- sol/table.hpp | 7 ++++++- sol/traits.hpp | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sol/table.hpp b/sol/table.hpp index 7cefa37c..3ea92e20 100644 --- a/sol/table.hpp +++ b/sol/table.hpp @@ -217,10 +217,15 @@ private: proxy(table& t, T& key): t(t), key(key) {} template - void operator=(U&& other) { + DisableIf>> operator=(U&& other) { t.set(key, std::forward(other)); } + template + EnableIf>> operator=(U&& other) { + t.set_function(key, std::forward(other)); + } + template operator U() const { return t.get(key); diff --git a/sol/traits.hpp b/sol/traits.hpp index f49b0ca5..63f5b9be 100644 --- a/sol/traits.hpp +++ b/sol/traits.hpp @@ -34,11 +34,14 @@ using DisableIf = typename std::enable_if::type; template using Unqualified = typename std::remove_reference::type>::type; +template +using Decay = typename std::decay::type; + namespace detail { // code borrowed from Gears // https://github.com/Rapptz/Gears/ template -struct is_function_impl : std::is_function {}; +struct is_function_impl : std::is_function::type> {}; template struct is_function_impl>>> { @@ -64,9 +67,6 @@ using Bool = std::integral_constant; template struct Function : Bool::value> {}; - -template -using Decay = typename std::decay::type; } // sol #endif // SOL_TRAITS_HPP \ No newline at end of file