diff --git a/Optional b/Optional index 45112c08..70ad9085 160000 --- a/Optional +++ b/Optional @@ -1 +1 @@ -Subproject commit 45112c085a4ca75b5591dde3bf46faf4969c3026 +Subproject commit 70ad908553b0bbac144452ce0dcc98d6dfe565a4 diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index 5f6f10a4..9e01bf1d 100644 --- a/single/sol/sol.hpp +++ b/single/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2016-09-04 15:42:29.271382 UTC -// This header was generated with sol v2.12.2 (revision cb0116a) +// Generated 2016-09-11 00:47:45.107316 UTC +// This header was generated with sol v2.12.3 (revision edb8eac) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -1442,10 +1442,10 @@ public: return ref != nullptr; } - template - constexpr typename ::std::decay::type value_or(V&& v) const + template + constexpr T& value_or(V&& v) const { - return *this ? **this : detail_::convert::type>(constexpr_forward(v)); + return *this ? **this : detail_::convert(constexpr_forward(v)); } }; @@ -9382,7 +9382,7 @@ namespace sol { namespace usertype_detail { struct no_comp { template - bool operator()(A&&, B&&) { + bool operator()(A&&, B&&) const { return false; } }; diff --git a/sol/usertype_metatable.hpp b/sol/usertype_metatable.hpp index c29e0082..a41131f7 100644 --- a/sol/usertype_metatable.hpp +++ b/sol/usertype_metatable.hpp @@ -37,7 +37,7 @@ namespace sol { namespace usertype_detail { struct no_comp { template - bool operator()(A&&, B&&) { + bool operator()(A&&, B&&) const { return false; } }; diff --git a/test_usertypes.cpp b/test_usertypes.cpp index 16413e01..d6736388 100644 --- a/test_usertypes.cpp +++ b/test_usertypes.cpp @@ -72,6 +72,18 @@ public: } }; +class abstract_A { +public: + virtual void a() = 0; +}; + +class abstract_B : public abstract_A { +public: + virtual void a() override { + INFO("overridden a() in B : public A - BARK"); + } +}; + struct Vec { float x, y, z; Vec(float x, float y, float z) : x{ x }, y{ y }, z{ z } {} @@ -1405,3 +1417,13 @@ TEST_CASE("usertype/unique_usertype-check", "make sure unique usertypes don't ge my_func(std::make_shared()); }); } + +TEST_CASE("usertype/abstract-base-class", "Ensure that abstract base classes and such can be registered") { + + sol::state lua; + lua.new_usertype("A", "a", &abstract_A::a); + lua.new_usertype("B", sol::base_classes, sol::bases()); + lua.script(R"(local b = B.new() +b:a() +)"); +}