mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
fix problem with instantiations of abstract classes in optional reference
This commit is contained in:
parent
edb8eacac7
commit
5dface25fb
2
Optional
2
Optional
@ -1 +1 @@
|
|||||||
Subproject commit 45112c085a4ca75b5591dde3bf46faf4969c3026
|
Subproject commit 70ad908553b0bbac144452ce0dcc98d6dfe565a4
|
@ -20,8 +20,8 @@
|
|||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// This file was generated with a script.
|
// This file was generated with a script.
|
||||||
// Generated 2016-09-04 15:42:29.271382 UTC
|
// Generated 2016-09-11 00:47:45.107316 UTC
|
||||||
// This header was generated with sol v2.12.2 (revision cb0116a)
|
// This header was generated with sol v2.12.3 (revision edb8eac)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||||
@ -1442,10 +1442,10 @@ public:
|
|||||||
return ref != nullptr;
|
return ref != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class V>
|
template <typename V>
|
||||||
constexpr typename ::std::decay<T>::type value_or(V&& v) const
|
constexpr T& value_or(V&& v) const
|
||||||
{
|
{
|
||||||
return *this ? **this : detail_::convert<typename ::std::decay<T>::type>(constexpr_forward<V>(v));
|
return *this ? **this : detail_::convert<T&>(constexpr_forward<V>(v));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -9382,7 +9382,7 @@ namespace sol {
|
|||||||
namespace usertype_detail {
|
namespace usertype_detail {
|
||||||
struct no_comp {
|
struct no_comp {
|
||||||
template <typename A, typename B>
|
template <typename A, typename B>
|
||||||
bool operator()(A&&, B&&) {
|
bool operator()(A&&, B&&) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,7 @@ namespace sol {
|
|||||||
namespace usertype_detail {
|
namespace usertype_detail {
|
||||||
struct no_comp {
|
struct no_comp {
|
||||||
template <typename A, typename B>
|
template <typename A, typename B>
|
||||||
bool operator()(A&&, B&&) {
|
bool operator()(A&&, B&&) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -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 {
|
struct Vec {
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
Vec(float x, float y, float z) : x{ x }, y{ y }, z{ 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<Entity>());
|
my_func(std::make_shared<Entity>());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("usertype/abstract-base-class", "Ensure that abstract base classes and such can be registered") {
|
||||||
|
|
||||||
|
sol::state lua;
|
||||||
|
lua.new_usertype<abstract_A>("A", "a", &abstract_A::a);
|
||||||
|
lua.new_usertype<abstract_B>("B", sol::base_classes, sol::bases<abstract_A>());
|
||||||
|
lua.script(R"(local b = B.new()
|
||||||
|
b:a()
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user