mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-13 11:17:06 +07:00
reduce the number of ::instance() calls
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,10 @@ namespace
|
||||
|
||||
TEST_CASE("meta/meta_features/diamond") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::uinst;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
meta::class_<A>();
|
||||
meta::class_<B>().base_<A>();
|
||||
@@ -120,43 +124,43 @@ TEST_CASE("meta/meta_features/diamond") {
|
||||
using meta::detail::pointer_upcast;
|
||||
{
|
||||
A a;
|
||||
CHECK(pointer_upcast<A>(&a) == &a);
|
||||
CHECK_FALSE(pointer_upcast<B>(&a));
|
||||
CHECK_FALSE(pointer_upcast<C>(&a));
|
||||
CHECK_FALSE(pointer_upcast<D>(&a));
|
||||
CHECK_FALSE(pointer_upcast<E>(&a));
|
||||
CHECK(pointer_upcast<A>(r, &a) == &a);
|
||||
CHECK_FALSE(pointer_upcast<B>(r, &a));
|
||||
CHECK_FALSE(pointer_upcast<C>(r, &a));
|
||||
CHECK_FALSE(pointer_upcast<D>(r, &a));
|
||||
CHECK_FALSE(pointer_upcast<E>(r, &a));
|
||||
}
|
||||
{
|
||||
const B b;
|
||||
CHECK(pointer_upcast<A>(&b) == &b);
|
||||
CHECK(pointer_upcast<B>(&b) == &b);
|
||||
CHECK_FALSE(pointer_upcast<C>(&b));
|
||||
CHECK_FALSE(pointer_upcast<D>(&b));
|
||||
CHECK_FALSE(pointer_upcast<E>(&b));
|
||||
CHECK(pointer_upcast<A>(r, &b) == &b);
|
||||
CHECK(pointer_upcast<B>(r, &b) == &b);
|
||||
CHECK_FALSE(pointer_upcast<C>(r, &b));
|
||||
CHECK_FALSE(pointer_upcast<D>(r, &b));
|
||||
CHECK_FALSE(pointer_upcast<E>(r, &b));
|
||||
}
|
||||
{
|
||||
C c;
|
||||
CHECK(pointer_upcast<A>(&c) == &c);
|
||||
CHECK_FALSE(pointer_upcast<B>(&c));
|
||||
CHECK(pointer_upcast<C>(&c) == &c);
|
||||
CHECK_FALSE(pointer_upcast<D>(&c));
|
||||
CHECK_FALSE(pointer_upcast<E>(&c));
|
||||
CHECK(pointer_upcast<A>(r, &c) == &c);
|
||||
CHECK_FALSE(pointer_upcast<B>(r, &c));
|
||||
CHECK(pointer_upcast<C>(r, &c) == &c);
|
||||
CHECK_FALSE(pointer_upcast<D>(r, &c));
|
||||
CHECK_FALSE(pointer_upcast<E>(r, &c));
|
||||
}
|
||||
{
|
||||
const D d;
|
||||
CHECK(pointer_upcast<A>(&d) == &d);
|
||||
CHECK(pointer_upcast<B>(&d) == &d);
|
||||
CHECK(pointer_upcast<C>(&d) == &d);
|
||||
CHECK(pointer_upcast<D>(&d) == &d);
|
||||
CHECK_FALSE(pointer_upcast<E>(&d));
|
||||
CHECK(pointer_upcast<A>(r, &d) == &d);
|
||||
CHECK(pointer_upcast<B>(r, &d) == &d);
|
||||
CHECK(pointer_upcast<C>(r, &d) == &d);
|
||||
CHECK(pointer_upcast<D>(r, &d) == &d);
|
||||
CHECK_FALSE(pointer_upcast<E>(r, &d));
|
||||
}
|
||||
{
|
||||
E e;
|
||||
CHECK_FALSE(pointer_upcast<A>(&e));
|
||||
CHECK_FALSE(pointer_upcast<B>(&e));
|
||||
CHECK_FALSE(pointer_upcast<C>(&e));
|
||||
CHECK_FALSE(pointer_upcast<D>(&e));
|
||||
CHECK(pointer_upcast<E>(&e) == &e);
|
||||
CHECK_FALSE(pointer_upcast<A>(r, &e));
|
||||
CHECK_FALSE(pointer_upcast<B>(r, &e));
|
||||
CHECK_FALSE(pointer_upcast<C>(r, &e));
|
||||
CHECK_FALSE(pointer_upcast<D>(r, &e));
|
||||
CHECK(pointer_upcast<E>(r, &e) == &e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,155 +170,155 @@ TEST_CASE("meta/meta_features/diamond") {
|
||||
meta::uvalue a_val{&a};
|
||||
CHECK(*static_cast<A**>(a_val.get_data()) == &a);
|
||||
|
||||
meta::detail::uarg a_arg{a_val};
|
||||
uarg a_arg{r, a_val};
|
||||
|
||||
CHECK(a_arg.can_cast_to<A*>());
|
||||
CHECK(!a_arg.can_cast_to<B*>());
|
||||
CHECK(!a_arg.can_cast_to<C*>());
|
||||
CHECK(!a_arg.can_cast_to<D*>());
|
||||
CHECK(!a_arg.can_cast_to<E*>());
|
||||
CHECK(a_arg.can_cast_to<A*>(r));
|
||||
CHECK(!a_arg.can_cast_to<B*>(r));
|
||||
CHECK(!a_arg.can_cast_to<C*>(r));
|
||||
CHECK(!a_arg.can_cast_to<D*>(r));
|
||||
CHECK(!a_arg.can_cast_to<E*>(r));
|
||||
|
||||
CHECK(a_arg.cast<A*>() == static_cast<A*>(&a));
|
||||
CHECK(a_arg.cast<A*>(r) == static_cast<A*>(&a));
|
||||
}
|
||||
{
|
||||
B b;
|
||||
meta::uvalue b_val{&b};
|
||||
CHECK(*static_cast<B**>(b_val.get_data()) == &b);
|
||||
|
||||
meta::detail::uarg b_arg{b_val};
|
||||
uarg b_arg{r, b_val};
|
||||
|
||||
CHECK(b_arg.can_cast_to<A*>());
|
||||
CHECK(b_arg.can_cast_to<B*>());
|
||||
CHECK(!b_arg.can_cast_to<C*>());
|
||||
CHECK(!b_arg.can_cast_to<D*>());
|
||||
CHECK(!b_arg.can_cast_to<E*>());
|
||||
CHECK(b_arg.can_cast_to<A*>(r));
|
||||
CHECK(b_arg.can_cast_to<B*>(r));
|
||||
CHECK(!b_arg.can_cast_to<C*>(r));
|
||||
CHECK(!b_arg.can_cast_to<D*>(r));
|
||||
CHECK(!b_arg.can_cast_to<E*>(r));
|
||||
|
||||
CHECK(b_arg.cast<A*>() == static_cast<A*>(&b));
|
||||
CHECK(b_arg.cast<B*>() == static_cast<B*>(&b));
|
||||
CHECK(b_arg.cast<A*>(r) == static_cast<A*>(&b));
|
||||
CHECK(b_arg.cast<B*>(r) == static_cast<B*>(&b));
|
||||
}
|
||||
{
|
||||
C c;
|
||||
meta::uvalue c_val{&c};
|
||||
CHECK(*static_cast<C**>(c_val.get_data()) == &c);
|
||||
|
||||
meta::detail::uarg c_arg{c_val};
|
||||
uarg c_arg{r, c_val};
|
||||
|
||||
CHECK(c_arg.can_cast_to<A*>());
|
||||
CHECK(!c_arg.can_cast_to<B*>());
|
||||
CHECK(c_arg.can_cast_to<C*>());
|
||||
CHECK(!c_arg.can_cast_to<D*>());
|
||||
CHECK(!c_arg.can_cast_to<E*>());
|
||||
CHECK(c_arg.can_cast_to<A*>(r));
|
||||
CHECK(!c_arg.can_cast_to<B*>(r));
|
||||
CHECK(c_arg.can_cast_to<C*>(r));
|
||||
CHECK(!c_arg.can_cast_to<D*>(r));
|
||||
CHECK(!c_arg.can_cast_to<E*>(r));
|
||||
|
||||
CHECK(c_arg.cast<A*>() == static_cast<A*>(&c));
|
||||
CHECK(c_arg.cast<C*>() == static_cast<C*>(&c));
|
||||
CHECK(c_arg.cast<A*>(r) == static_cast<A*>(&c));
|
||||
CHECK(c_arg.cast<C*>(r) == static_cast<C*>(&c));
|
||||
}
|
||||
{
|
||||
D d;
|
||||
meta::uvalue d_val{&d};
|
||||
CHECK(*static_cast<D**>(d_val.get_data()) == &d);
|
||||
|
||||
meta::detail::uarg d_arg{d_val};
|
||||
uarg d_arg{r, d_val};
|
||||
|
||||
CHECK(d_arg.can_cast_to<A*>());
|
||||
CHECK(d_arg.can_cast_to<B*>());
|
||||
CHECK(d_arg.can_cast_to<C*>());
|
||||
CHECK(d_arg.can_cast_to<D*>());
|
||||
CHECK(!d_arg.can_cast_to<E*>());
|
||||
CHECK(d_arg.can_cast_to<A*>(r));
|
||||
CHECK(d_arg.can_cast_to<B*>(r));
|
||||
CHECK(d_arg.can_cast_to<C*>(r));
|
||||
CHECK(d_arg.can_cast_to<D*>(r));
|
||||
CHECK(!d_arg.can_cast_to<E*>(r));
|
||||
|
||||
CHECK(d_arg.cast<A*>() == static_cast<A*>(&d));
|
||||
CHECK(d_arg.cast<B*>() == static_cast<B*>(&d));
|
||||
CHECK(d_arg.cast<C*>() == static_cast<C*>(&d));
|
||||
CHECK(d_arg.cast<D*>() == static_cast<D*>(&d));
|
||||
CHECK(d_arg.cast<A*>(r) == static_cast<A*>(&d));
|
||||
CHECK(d_arg.cast<B*>(r) == static_cast<B*>(&d));
|
||||
CHECK(d_arg.cast<C*>(r) == static_cast<C*>(&d));
|
||||
CHECK(d_arg.cast<D*>(r) == static_cast<D*>(&d));
|
||||
}
|
||||
{
|
||||
E e;
|
||||
meta::uvalue e_val{&e};
|
||||
CHECK(*static_cast<E**>(e_val.get_data()) == &e);
|
||||
|
||||
meta::detail::uarg e_arg{e_val};
|
||||
uarg e_arg{r, e_val};
|
||||
|
||||
CHECK(!e_arg.can_cast_to<A*>());
|
||||
CHECK(!e_arg.can_cast_to<B*>());
|
||||
CHECK(!e_arg.can_cast_to<C*>());
|
||||
CHECK(!e_arg.can_cast_to<D*>());
|
||||
CHECK(e_arg.can_cast_to<E*>());
|
||||
CHECK(!e_arg.can_cast_to<A*>(r));
|
||||
CHECK(!e_arg.can_cast_to<B*>(r));
|
||||
CHECK(!e_arg.can_cast_to<C*>(r));
|
||||
CHECK(!e_arg.can_cast_to<D*>(r));
|
||||
CHECK(e_arg.can_cast_to<E*>(r));
|
||||
|
||||
CHECK(e_arg.cast<E*>() == static_cast<E*>(&e));
|
||||
CHECK(e_arg.cast<E*>(r) == static_cast<E*>(&e));
|
||||
}
|
||||
}
|
||||
|
||||
SUBCASE("inst/cast") {
|
||||
{
|
||||
meta::uvalue a_val{A{}};
|
||||
meta::detail::uinst a_inst{a_val};
|
||||
uinst a_inst{r, a_val};
|
||||
|
||||
CHECK(a_inst.can_cast_to<A&>());
|
||||
CHECK_FALSE(a_inst.can_cast_to<B&>());
|
||||
CHECK_FALSE(a_inst.can_cast_to<C&>());
|
||||
CHECK_FALSE(a_inst.can_cast_to<D&>());
|
||||
CHECK_FALSE(a_inst.can_cast_to<E&>());
|
||||
CHECK(a_inst.can_cast_to<A&>(r));
|
||||
CHECK_FALSE(a_inst.can_cast_to<B&>(r));
|
||||
CHECK_FALSE(a_inst.can_cast_to<C&>(r));
|
||||
CHECK_FALSE(a_inst.can_cast_to<D&>(r));
|
||||
CHECK_FALSE(a_inst.can_cast_to<E&>(r));
|
||||
|
||||
CHECK(&a_inst.cast<A&>() == &a_val.get_as<A>());
|
||||
CHECK(&a_inst.cast<A&>(r) == &a_val.get_as<A>());
|
||||
}
|
||||
{
|
||||
meta::uvalue b_val{B{}};
|
||||
meta::detail::uinst b_inst{b_val};
|
||||
uinst b_inst{r, b_val};
|
||||
|
||||
CHECK(b_inst.can_cast_to<A&>());
|
||||
CHECK(b_inst.can_cast_to<B&>());
|
||||
CHECK_FALSE(b_inst.can_cast_to<C&>());
|
||||
CHECK_FALSE(b_inst.can_cast_to<D&>());
|
||||
CHECK_FALSE(b_inst.can_cast_to<E&>());
|
||||
CHECK(b_inst.can_cast_to<A&>(r));
|
||||
CHECK(b_inst.can_cast_to<B&>(r));
|
||||
CHECK_FALSE(b_inst.can_cast_to<C&>(r));
|
||||
CHECK_FALSE(b_inst.can_cast_to<D&>(r));
|
||||
CHECK_FALSE(b_inst.can_cast_to<E&>(r));
|
||||
|
||||
CHECK(&b_inst.cast<A&>() == &b_val.get_as<B>());
|
||||
CHECK(&b_inst.cast<B&>() == &b_val.get_as<B>());
|
||||
CHECK(&b_inst.cast<A&>(r) == &b_val.get_as<B>());
|
||||
CHECK(&b_inst.cast<B&>(r) == &b_val.get_as<B>());
|
||||
|
||||
CHECK(&b_inst.cast<A&>() == &b_val.get_as<B>());
|
||||
CHECK(&b_inst.cast<A&>(r) == &b_val.get_as<B>());
|
||||
}
|
||||
{
|
||||
meta::uvalue c_val{C{}};
|
||||
meta::detail::uinst c_inst{c_val};
|
||||
uinst c_inst{r, c_val};
|
||||
|
||||
CHECK(c_inst.can_cast_to<A&>());
|
||||
CHECK_FALSE(c_inst.can_cast_to<B&>());
|
||||
CHECK(c_inst.can_cast_to<C&>());
|
||||
CHECK_FALSE(c_inst.can_cast_to<D&>());
|
||||
CHECK_FALSE(c_inst.can_cast_to<E&>());
|
||||
CHECK(c_inst.can_cast_to<A&>(r));
|
||||
CHECK_FALSE(c_inst.can_cast_to<B&>(r));
|
||||
CHECK(c_inst.can_cast_to<C&>(r));
|
||||
CHECK_FALSE(c_inst.can_cast_to<D&>(r));
|
||||
CHECK_FALSE(c_inst.can_cast_to<E&>(r));
|
||||
|
||||
CHECK(&c_inst.cast<A&>() == &c_val.get_as<C>());
|
||||
CHECK(&c_inst.cast<C&>() == &c_val.get_as<C>());
|
||||
CHECK(&c_inst.cast<A&>(r) == &c_val.get_as<C>());
|
||||
CHECK(&c_inst.cast<C&>(r) == &c_val.get_as<C>());
|
||||
}
|
||||
{
|
||||
meta::uvalue d_val{D{}};
|
||||
meta::detail::uinst d_inst{d_val};
|
||||
uinst d_inst{r, d_val};
|
||||
|
||||
CHECK(d_inst.can_cast_to<A&>());
|
||||
CHECK(d_inst.can_cast_to<B&>());
|
||||
CHECK(d_inst.can_cast_to<C&>());
|
||||
CHECK(d_inst.can_cast_to<D&>());
|
||||
CHECK_FALSE(d_inst.can_cast_to<E&>());
|
||||
CHECK(d_inst.can_cast_to<A&>(r));
|
||||
CHECK(d_inst.can_cast_to<B&>(r));
|
||||
CHECK(d_inst.can_cast_to<C&>(r));
|
||||
CHECK(d_inst.can_cast_to<D&>(r));
|
||||
CHECK_FALSE(d_inst.can_cast_to<E&>(r));
|
||||
|
||||
CHECK(&d_inst.cast<A&>() == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<B&>() == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<C&>() == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<D&>() == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<A&>(r) == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<B&>(r) == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<C&>(r) == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<D&>(r) == &d_val.get_as<D>());
|
||||
|
||||
CHECK(&d_inst.cast<A&>() == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<B&>() == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<C&>() == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<D&>() == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<A&>(r) == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<B&>(r) == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<C&>(r) == &d_val.get_as<D>());
|
||||
CHECK(&d_inst.cast<D&>(r) == &d_val.get_as<D>());
|
||||
}
|
||||
{
|
||||
meta::uvalue e_val{E{}};
|
||||
meta::detail::uinst e_inst{e_val};
|
||||
uinst e_inst{r, e_val};
|
||||
|
||||
CHECK_FALSE(e_inst.can_cast_to<A&>());
|
||||
CHECK_FALSE(e_inst.can_cast_to<B&>());
|
||||
CHECK_FALSE(e_inst.can_cast_to<C&>());
|
||||
CHECK_FALSE(e_inst.can_cast_to<D&>());
|
||||
CHECK(e_inst.can_cast_to<E&>());
|
||||
CHECK_FALSE(e_inst.can_cast_to<A&>(r));
|
||||
CHECK_FALSE(e_inst.can_cast_to<B&>(r));
|
||||
CHECK_FALSE(e_inst.can_cast_to<C&>(r));
|
||||
CHECK_FALSE(e_inst.can_cast_to<D&>(r));
|
||||
CHECK(e_inst.can_cast_to<E&>(r));
|
||||
|
||||
CHECK(&e_inst.cast<E&>() == &e_val.get_as<E>());
|
||||
CHECK(&e_inst.cast<E&>(r) == &e_val.get_as<E>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ TEST_CASE("meta/meta_utilities/arg2") {
|
||||
TEST_CASE("meta/meta_utilities/arg2/cast") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
auto LV = []() -> D& { static D v; return v; };
|
||||
auto CLV = []() -> const D& { static D v; return v; };
|
||||
@@ -100,254 +102,254 @@ TEST_CASE("meta/meta_utilities/arg2/cast") {
|
||||
A::move_ctors_ = 0;
|
||||
|
||||
SUBCASE("LV") {
|
||||
CHECK(uarg{LV()}.can_cast_to<A>());
|
||||
CHECK(uarg{LV()}.can_cast_to<const A>());
|
||||
CHECK(uarg{LV()}.can_cast_to<A&>());
|
||||
CHECK(uarg{LV()}.can_cast_to<const A&>());
|
||||
CHECK_FALSE(uarg{LV()}.can_cast_to<A&&>());
|
||||
CHECK_FALSE(uarg{LV()}.can_cast_to<const A&&>());
|
||||
CHECK(uarg{r, LV()}.can_cast_to<A>(r));
|
||||
CHECK(uarg{r, LV()}.can_cast_to<const A>(r));
|
||||
CHECK(uarg{r, LV()}.can_cast_to<A&>(r));
|
||||
CHECK(uarg{r, LV()}.can_cast_to<const A&>(r));
|
||||
CHECK_FALSE(uarg{r, LV()}.can_cast_to<A&&>(r));
|
||||
CHECK_FALSE(uarg{r, LV()}.can_cast_to<const A&&>(r));
|
||||
|
||||
CHECK(A::copy_ctors_ == 0);
|
||||
CHECK(A::move_ctors_ == 0);
|
||||
|
||||
CHECK(uarg{LV()}.cast<A>().f() == 1);
|
||||
CHECK(uarg{LV()}.cast<const A>().f() == 1);
|
||||
CHECK(uarg{LV()}.cast<A&>().f() == 1);
|
||||
CHECK(uarg{LV()}.cast<const A&>().f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{LV()}.cast<A&&>());
|
||||
// CHECK_THROWS(std::ignore = uarg{LV()}.cast<const A&&>());
|
||||
CHECK(uarg{r, LV()}.cast<A>(r).f() == 1);
|
||||
CHECK(uarg{r, LV()}.cast<const A>(r).f() == 1);
|
||||
CHECK(uarg{r, LV()}.cast<A&>(r).f() == 1);
|
||||
CHECK(uarg{r, LV()}.cast<const A&>(r).f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, LV()}.cast<A&&>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, LV()}.cast<const A&&>(r));
|
||||
|
||||
CHECK(A::copy_ctors_ == 2);
|
||||
CHECK(A::move_ctors_ == 0);
|
||||
}
|
||||
|
||||
SUBCASE("CLV") {
|
||||
CHECK(uarg{CLV()}.can_cast_to<A>());
|
||||
CHECK(uarg{CLV()}.can_cast_to<const A>());
|
||||
CHECK_FALSE(uarg{CLV()}.can_cast_to<A&>());
|
||||
CHECK(uarg{CLV()}.can_cast_to<const A&>());
|
||||
CHECK_FALSE(uarg{CLV()}.can_cast_to<A&&>());
|
||||
CHECK_FALSE(uarg{CLV()}.can_cast_to<const A&&>());
|
||||
CHECK(uarg{r, CLV()}.can_cast_to<A>(r));
|
||||
CHECK(uarg{r, CLV()}.can_cast_to<const A>(r));
|
||||
CHECK_FALSE(uarg{r, CLV()}.can_cast_to<A&>(r));
|
||||
CHECK(uarg{r, CLV()}.can_cast_to<const A&>(r));
|
||||
CHECK_FALSE(uarg{r, CLV()}.can_cast_to<A&&>(r));
|
||||
CHECK_FALSE(uarg{r, CLV()}.can_cast_to<const A&&>(r));
|
||||
|
||||
CHECK(A::copy_ctors_ == 0);
|
||||
CHECK(A::move_ctors_ == 0);
|
||||
|
||||
CHECK(uarg{CLV()}.cast<A>().f() == 1);
|
||||
CHECK(uarg{CLV()}.cast<const A>().f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{CLV()}.cast<A&>());
|
||||
CHECK(uarg{CLV()}.cast<const A&>().f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{CLV()}.cast<A&&>());
|
||||
// CHECK_THROWS(std::ignore = uarg{CLV()}.cast<const A&&>());
|
||||
CHECK(uarg{r, CLV()}.cast<A>(r).f() == 1);
|
||||
CHECK(uarg{r, CLV()}.cast<const A>(r).f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CLV()}.cast<A&>(r));
|
||||
CHECK(uarg{r, CLV()}.cast<const A&>(r).f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CLV()}.cast<A&&>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CLV()}.cast<const A&&>(r));
|
||||
|
||||
CHECK(A::copy_ctors_ == 2);
|
||||
CHECK(A::move_ctors_ == 0);
|
||||
}
|
||||
|
||||
SUBCASE("XV") {
|
||||
CHECK(uarg{XV()}.can_cast_to<A>());
|
||||
CHECK(uarg{XV()}.can_cast_to<const A>());
|
||||
CHECK_FALSE(uarg{XV()}.can_cast_to<A&>());
|
||||
CHECK(uarg{XV()}.can_cast_to<const A&>());
|
||||
CHECK(uarg{XV()}.can_cast_to<A&&>());
|
||||
CHECK(uarg{XV()}.can_cast_to<const A&&>());
|
||||
CHECK(uarg{r, XV()}.can_cast_to<A>(r));
|
||||
CHECK(uarg{r, XV()}.can_cast_to<const A>(r));
|
||||
CHECK_FALSE(uarg{r, XV()}.can_cast_to<A&>(r));
|
||||
CHECK(uarg{r, XV()}.can_cast_to<const A&>(r));
|
||||
CHECK(uarg{r, XV()}.can_cast_to<A&&>(r));
|
||||
CHECK(uarg{r, XV()}.can_cast_to<const A&&>(r));
|
||||
|
||||
CHECK(A::copy_ctors_ == 0);
|
||||
CHECK(A::move_ctors_ == 0);
|
||||
|
||||
CHECK(uarg{XV()}.cast<A>().f() == 1);
|
||||
CHECK(uarg{XV()}.cast<const A>().f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{XV()}.cast<A&>());
|
||||
CHECK(uarg{XV()}.cast<const A&>().f() == 1);
|
||||
CHECK(uarg{XV()}.cast<A&&>().f() == 1);
|
||||
CHECK(uarg{XV()}.cast<const A&&>().f() == 1);
|
||||
CHECK(uarg{r, XV()}.cast<A>(r).f() == 1);
|
||||
CHECK(uarg{r, XV()}.cast<const A>(r).f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, XV()}.cast<A&>(r));
|
||||
CHECK(uarg{r, XV()}.cast<const A&>(r).f() == 1);
|
||||
CHECK(uarg{r, XV()}.cast<A&&>(r).f() == 1);
|
||||
CHECK(uarg{r, XV()}.cast<const A&&>(r).f() == 1);
|
||||
|
||||
CHECK(A::copy_ctors_ == 0);
|
||||
CHECK(A::move_ctors_ == 2);
|
||||
}
|
||||
|
||||
SUBCASE("CXV") {
|
||||
CHECK(uarg{CXV()}.can_cast_to<A>());
|
||||
CHECK(uarg{CXV()}.can_cast_to<const A>());
|
||||
CHECK_FALSE(uarg{CXV()}.can_cast_to<A&>());
|
||||
CHECK(uarg{CXV()}.can_cast_to<const A&>());
|
||||
CHECK_FALSE(uarg{CXV()}.can_cast_to<A&&>());
|
||||
CHECK(uarg{CXV()}.can_cast_to<const A&&>());
|
||||
CHECK(uarg{r, CXV()}.can_cast_to<A>(r));
|
||||
CHECK(uarg{r, CXV()}.can_cast_to<const A>(r));
|
||||
CHECK_FALSE(uarg{r, CXV()}.can_cast_to<A&>(r));
|
||||
CHECK(uarg{r, CXV()}.can_cast_to<const A&>(r));
|
||||
CHECK_FALSE(uarg{r, CXV()}.can_cast_to<A&&>(r));
|
||||
CHECK(uarg{r, CXV()}.can_cast_to<const A&&>(r));
|
||||
|
||||
CHECK(A::copy_ctors_ == 0);
|
||||
CHECK(A::move_ctors_ == 0);
|
||||
|
||||
CHECK(uarg{CXV()}.cast<A>().f() == 1);
|
||||
CHECK(uarg{CXV()}.cast<const A>().f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{CXV()}.cast<A&>());
|
||||
CHECK(uarg{CXV()}.cast<const A&>().f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{CXV()}.cast<A&&>());
|
||||
CHECK(uarg{CXV()}.cast<const A&&>().f() == 1);
|
||||
CHECK(uarg{r, CXV()}.cast<A>(r).f() == 1);
|
||||
CHECK(uarg{r, CXV()}.cast<const A>(r).f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CXV()}.cast<A&>(r));
|
||||
CHECK(uarg{r, CXV()}.cast<const A&>(r).f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CXV()}.cast<A&&>(r));
|
||||
CHECK(uarg{r, CXV()}.cast<const A&&>(r).f() == 1);
|
||||
|
||||
CHECK(A::copy_ctors_ == 2);
|
||||
CHECK(A::move_ctors_ == 0);
|
||||
}
|
||||
|
||||
SUBCASE("PRV") {
|
||||
CHECK(uarg{PRV()}.can_cast_to<A>());
|
||||
CHECK(uarg{PRV()}.can_cast_to<const A>());
|
||||
CHECK_FALSE(uarg{PRV()}.can_cast_to<A&>());
|
||||
CHECK(uarg{PRV()}.can_cast_to<const A&>());
|
||||
CHECK(uarg{PRV()}.can_cast_to<A&&>());
|
||||
CHECK(uarg{PRV()}.can_cast_to<const A&&>());
|
||||
CHECK(uarg{r, PRV()}.can_cast_to<A>(r));
|
||||
CHECK(uarg{r, PRV()}.can_cast_to<const A>(r));
|
||||
CHECK_FALSE(uarg{r, PRV()}.can_cast_to<A&>(r));
|
||||
CHECK(uarg{r, PRV()}.can_cast_to<const A&>(r));
|
||||
CHECK(uarg{r, PRV()}.can_cast_to<A&&>(r));
|
||||
CHECK(uarg{r, PRV()}.can_cast_to<const A&&>(r));
|
||||
|
||||
CHECK(A::copy_ctors_ == 0);
|
||||
CHECK(A::move_ctors_ == 0);
|
||||
|
||||
CHECK(uarg{PRV()}.cast<A>().f() == 1);
|
||||
CHECK(uarg{PRV()}.cast<const A>().f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{PRV()}.cast<A&>());
|
||||
CHECK(uarg{PRV()}.cast<const A&>().f() == 1);
|
||||
CHECK(uarg{PRV()}.cast<A&&>().f() == 1);
|
||||
CHECK(uarg{PRV()}.cast<const A&&>().f() == 1);
|
||||
CHECK(uarg{r, PRV()}.cast<A>(r).f() == 1);
|
||||
CHECK(uarg{r, PRV()}.cast<const A>(r).f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, PRV()}.cast<A&>(r));
|
||||
CHECK(uarg{r, PRV()}.cast<const A&>(r).f() == 1);
|
||||
CHECK(uarg{r, PRV()}.cast<A&&>(r).f() == 1);
|
||||
CHECK(uarg{r, PRV()}.cast<const A&&>(r).f() == 1);
|
||||
|
||||
CHECK(A::copy_ctors_ == 0);
|
||||
CHECK(A::move_ctors_ == 2);
|
||||
}
|
||||
|
||||
SUBCASE("CPRV") {
|
||||
CHECK(uarg{CPRV()}.can_cast_to<A>());
|
||||
CHECK(uarg{CPRV()}.can_cast_to<const A>());
|
||||
CHECK_FALSE(uarg{CPRV()}.can_cast_to<A&>());
|
||||
CHECK(uarg{CPRV()}.can_cast_to<const A&>());
|
||||
CHECK_FALSE(uarg{CPRV()}.can_cast_to<A&&>());
|
||||
CHECK(uarg{CPRV()}.can_cast_to<const A&&>());
|
||||
CHECK(uarg{r, CPRV()}.can_cast_to<A>(r));
|
||||
CHECK(uarg{r, CPRV()}.can_cast_to<const A>(r));
|
||||
CHECK_FALSE(uarg{r, CPRV()}.can_cast_to<A&>(r));
|
||||
CHECK(uarg{r, CPRV()}.can_cast_to<const A&>(r));
|
||||
CHECK_FALSE(uarg{r, CPRV()}.can_cast_to<A&&>(r));
|
||||
CHECK(uarg{r, CPRV()}.can_cast_to<const A&&>(r));
|
||||
|
||||
CHECK(A::copy_ctors_ == 0);
|
||||
CHECK(A::move_ctors_ == 0);
|
||||
|
||||
CHECK(uarg{CPRV()}.cast<A>().f() == 1);
|
||||
CHECK(uarg{CPRV()}.cast<const A>().f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{CPRV()}.cast<A&>());
|
||||
CHECK(uarg{CPRV()}.cast<const A&>().f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{CPRV()}.cast<A&&>());
|
||||
CHECK(uarg{CPRV()}.cast<const A&&>().f() == 1);
|
||||
CHECK(uarg{r, CPRV()}.cast<A>(r).f() == 1);
|
||||
CHECK(uarg{r, CPRV()}.cast<const A>(r).f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CPRV()}.cast<A&>(r));
|
||||
CHECK(uarg{r, CPRV()}.cast<const A&>(r).f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CPRV()}.cast<A&&>(r));
|
||||
CHECK(uarg{r, CPRV()}.cast<const A&&>(r).f() == 1);
|
||||
|
||||
CHECK(A::copy_ctors_ == 2);
|
||||
CHECK(A::move_ctors_ == 0);
|
||||
}
|
||||
|
||||
SUBCASE("LV_PTR") {
|
||||
CHECK(uarg{LV_PTR()}.can_cast_to<A*>());
|
||||
CHECK(uarg{LV_PTR()}.can_cast_to<A* const>());
|
||||
CHECK(uarg{LV_PTR()}.can_cast_to<const A*>());
|
||||
CHECK(uarg{LV_PTR()}.can_cast_to<const A* const>());
|
||||
CHECK(uarg{r, LV_PTR()}.can_cast_to<A*>(r));
|
||||
CHECK(uarg{r, LV_PTR()}.can_cast_to<A* const>(r));
|
||||
CHECK(uarg{r, LV_PTR()}.can_cast_to<const A*>(r));
|
||||
CHECK(uarg{r, LV_PTR()}.can_cast_to<const A* const>(r));
|
||||
|
||||
CHECK(uarg{LV_PTR()}.cast<A*>()->f() == 1);
|
||||
CHECK(uarg{LV_PTR()}.cast<A* const>()->f() == 1);
|
||||
CHECK(uarg{LV_PTR()}.cast<const A*>()->f() == 1);
|
||||
CHECK(uarg{LV_PTR()}.cast<const A* const>()->f() == 1);
|
||||
CHECK(uarg{r, LV_PTR()}.cast<A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, LV_PTR()}.cast<A* const>(r)->f() == 1);
|
||||
CHECK(uarg{r, LV_PTR()}.cast<const A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, LV_PTR()}.cast<const A* const>(r)->f() == 1);
|
||||
}
|
||||
|
||||
SUBCASE("LV_CPTR") {
|
||||
CHECK_FALSE(uarg{LV_CPTR()}.can_cast_to<A*>());
|
||||
CHECK_FALSE(uarg{LV_CPTR()}.can_cast_to<A* const>());
|
||||
CHECK(uarg{LV_CPTR()}.can_cast_to<const A*>());
|
||||
CHECK(uarg{LV_CPTR()}.can_cast_to<const A* const>());
|
||||
CHECK_FALSE(uarg{r, LV_CPTR()}.can_cast_to<A*>(r));
|
||||
CHECK_FALSE(uarg{r, LV_CPTR()}.can_cast_to<A* const>(r));
|
||||
CHECK(uarg{r, LV_CPTR()}.can_cast_to<const A*>(r));
|
||||
CHECK(uarg{r, LV_CPTR()}.can_cast_to<const A* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{LV_CPTR()}.cast<A*>());
|
||||
// CHECK_THROWS(std::ignore = uarg{LV_CPTR()}.cast<A* const>());
|
||||
CHECK(uarg{LV_CPTR()}.cast<const A*>()->f() == 1);
|
||||
CHECK(uarg{LV_CPTR()}.cast<const A* const>()->f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, LV_CPTR()}.cast<A*>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, LV_CPTR()}.cast<A* const>(r));
|
||||
CHECK(uarg{r, LV_CPTR()}.cast<const A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, LV_CPTR()}.cast<const A* const>(r)->f() == 1);
|
||||
}
|
||||
|
||||
SUBCASE("CLV_PTR") {
|
||||
CHECK(uarg{CLV_PTR()}.can_cast_to<A*>());
|
||||
CHECK(uarg{CLV_PTR()}.can_cast_to<A* const>());
|
||||
CHECK(uarg{CLV_PTR()}.can_cast_to<const A*>());
|
||||
CHECK(uarg{CLV_PTR()}.can_cast_to<const A* const>());
|
||||
CHECK(uarg{r, CLV_PTR()}.can_cast_to<A*>(r));
|
||||
CHECK(uarg{r, CLV_PTR()}.can_cast_to<A* const>(r));
|
||||
CHECK(uarg{r, CLV_PTR()}.can_cast_to<const A*>(r));
|
||||
CHECK(uarg{r, CLV_PTR()}.can_cast_to<const A* const>(r));
|
||||
|
||||
CHECK(uarg{CLV_PTR()}.cast<A*>()->f() == 1);
|
||||
CHECK(uarg{CLV_PTR()}.cast<A* const>()->f() == 1);
|
||||
CHECK(uarg{CLV_PTR()}.cast<const A*>()->f() == 1);
|
||||
CHECK(uarg{CLV_PTR()}.cast<const A* const>()->f() == 1);
|
||||
CHECK(uarg{r, CLV_PTR()}.cast<A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, CLV_PTR()}.cast<A* const>(r)->f() == 1);
|
||||
CHECK(uarg{r, CLV_PTR()}.cast<const A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, CLV_PTR()}.cast<const A* const>(r)->f() == 1);
|
||||
}
|
||||
|
||||
SUBCASE("CLV_CPTR") {
|
||||
CHECK_FALSE(uarg{CLV_CPTR()}.can_cast_to<A*>());
|
||||
CHECK_FALSE(uarg{CLV_CPTR()}.can_cast_to<A* const>());
|
||||
CHECK(uarg{CLV_CPTR()}.can_cast_to<const A*>());
|
||||
CHECK(uarg{CLV_CPTR()}.can_cast_to<const A* const>());
|
||||
CHECK_FALSE(uarg{r, CLV_CPTR()}.can_cast_to<A*>(r));
|
||||
CHECK_FALSE(uarg{r, CLV_CPTR()}.can_cast_to<A* const>(r));
|
||||
CHECK(uarg{r, CLV_CPTR()}.can_cast_to<const A*>(r));
|
||||
CHECK(uarg{r, CLV_CPTR()}.can_cast_to<const A* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{CLV_CPTR()}.cast<A*>());
|
||||
// CHECK_THROWS(std::ignore = uarg{CLV_CPTR()}.cast<A* const>());
|
||||
CHECK(uarg{CLV_CPTR()}.cast<const A*>()->f() == 1);
|
||||
CHECK(uarg{CLV_CPTR()}.cast<const A* const>()->f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CLV_CPTR()}.cast<A*>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CLV_CPTR()}.cast<A* const>(r));
|
||||
CHECK(uarg{r, CLV_CPTR()}.cast<const A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, CLV_CPTR()}.cast<const A* const>(r)->f() == 1);
|
||||
}
|
||||
|
||||
SUBCASE("XV_PTR") {
|
||||
CHECK(uarg{XV_PTR()}.can_cast_to<A*>());
|
||||
CHECK(uarg{XV_PTR()}.can_cast_to<A* const>());
|
||||
CHECK(uarg{XV_PTR()}.can_cast_to<const A*>());
|
||||
CHECK(uarg{XV_PTR()}.can_cast_to<const A* const>());
|
||||
CHECK(uarg{r, XV_PTR()}.can_cast_to<A*>(r));
|
||||
CHECK(uarg{r, XV_PTR()}.can_cast_to<A* const>(r));
|
||||
CHECK(uarg{r, XV_PTR()}.can_cast_to<const A*>(r));
|
||||
CHECK(uarg{r, XV_PTR()}.can_cast_to<const A* const>(r));
|
||||
|
||||
CHECK(uarg{XV_PTR()}.cast<A*>()->f() == 1);
|
||||
CHECK(uarg{XV_PTR()}.cast<A* const>()->f() == 1);
|
||||
CHECK(uarg{XV_PTR()}.cast<const A*>()->f() == 1);
|
||||
CHECK(uarg{XV_PTR()}.cast<const A* const>()->f() == 1);
|
||||
CHECK(uarg{r, XV_PTR()}.cast<A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, XV_PTR()}.cast<A* const>(r)->f() == 1);
|
||||
CHECK(uarg{r, XV_PTR()}.cast<const A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, XV_PTR()}.cast<const A* const>(r)->f() == 1);
|
||||
}
|
||||
|
||||
SUBCASE("XV_CPTR") {
|
||||
CHECK_FALSE(uarg{XV_CPTR()}.can_cast_to<A*>());
|
||||
CHECK_FALSE(uarg{XV_CPTR()}.can_cast_to<A* const>());
|
||||
CHECK(uarg{XV_CPTR()}.can_cast_to<const A*>());
|
||||
CHECK(uarg{XV_CPTR()}.can_cast_to<const A* const>());
|
||||
CHECK_FALSE(uarg{r, XV_CPTR()}.can_cast_to<A*>(r));
|
||||
CHECK_FALSE(uarg{r, XV_CPTR()}.can_cast_to<A* const>(r));
|
||||
CHECK(uarg{r, XV_CPTR()}.can_cast_to<const A*>(r));
|
||||
CHECK(uarg{r, XV_CPTR()}.can_cast_to<const A* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{XV_CPTR()}.cast<A*>());
|
||||
// CHECK_THROWS(std::ignore = uarg{XV_CPTR()}.cast<A* const>());
|
||||
CHECK(uarg{XV_CPTR()}.cast<const A*>()->f() == 1);
|
||||
CHECK(uarg{XV_CPTR()}.cast<const A* const>()->f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, XV_CPTR()}.cast<A*>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, XV_CPTR()}.cast<A* const>(r));
|
||||
CHECK(uarg{r, XV_CPTR()}.cast<const A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, XV_CPTR()}.cast<const A* const>(r)->f() == 1);
|
||||
}
|
||||
|
||||
SUBCASE("CXV_PTR") {
|
||||
CHECK(uarg{CXV_PTR()}.can_cast_to<A*>());
|
||||
CHECK(uarg{CXV_PTR()}.can_cast_to<A* const>());
|
||||
CHECK(uarg{CXV_PTR()}.can_cast_to<const A*>());
|
||||
CHECK(uarg{CXV_PTR()}.can_cast_to<const A* const>());
|
||||
CHECK(uarg{r, CXV_PTR()}.can_cast_to<A*>(r));
|
||||
CHECK(uarg{r, CXV_PTR()}.can_cast_to<A* const>(r));
|
||||
CHECK(uarg{r, CXV_PTR()}.can_cast_to<const A*>(r));
|
||||
CHECK(uarg{r, CXV_PTR()}.can_cast_to<const A* const>(r));
|
||||
|
||||
CHECK(uarg{CXV_PTR()}.cast<A*>()->f() == 1);
|
||||
CHECK(uarg{CXV_PTR()}.cast<A* const>()->f() == 1);
|
||||
CHECK(uarg{CXV_PTR()}.cast<const A*>()->f() == 1);
|
||||
CHECK(uarg{CXV_PTR()}.cast<const A* const>()->f() == 1);
|
||||
CHECK(uarg{r, CXV_PTR()}.cast<A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, CXV_PTR()}.cast<A* const>(r)->f() == 1);
|
||||
CHECK(uarg{r, CXV_PTR()}.cast<const A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, CXV_PTR()}.cast<const A* const>(r)->f() == 1);
|
||||
}
|
||||
|
||||
SUBCASE("CXV_CPTR") {
|
||||
CHECK_FALSE(uarg{CXV_CPTR()}.can_cast_to<A*>());
|
||||
CHECK_FALSE(uarg{CXV_CPTR()}.can_cast_to<A* const>());
|
||||
CHECK(uarg{CXV_CPTR()}.can_cast_to<const A*>());
|
||||
CHECK(uarg{CXV_CPTR()}.can_cast_to<const A* const>());
|
||||
CHECK_FALSE(uarg{r, CXV_CPTR()}.can_cast_to<A*>(r));
|
||||
CHECK_FALSE(uarg{r, CXV_CPTR()}.can_cast_to<A* const>(r));
|
||||
CHECK(uarg{r, CXV_CPTR()}.can_cast_to<const A*>(r));
|
||||
CHECK(uarg{r, CXV_CPTR()}.can_cast_to<const A* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{CXV_CPTR()}.cast<A*>());
|
||||
// CHECK_THROWS(std::ignore = uarg{CXV_CPTR()}.cast<A* const>());
|
||||
CHECK(uarg{CXV_CPTR()}.cast<const A*>()->f() == 1);
|
||||
CHECK(uarg{CXV_CPTR()}.cast<const A* const>()->f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CXV_CPTR()}.cast<A*>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CXV_CPTR()}.cast<A* const>(r));
|
||||
CHECK(uarg{r, CXV_CPTR()}.cast<const A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, CXV_CPTR()}.cast<const A* const>(r)->f() == 1);
|
||||
}
|
||||
|
||||
SUBCASE("PRV_PTR") {
|
||||
CHECK(uarg{PRV_PTR()}.can_cast_to<A*>());
|
||||
CHECK(uarg{PRV_PTR()}.can_cast_to<A* const>());
|
||||
CHECK(uarg{PRV_PTR()}.can_cast_to<const A*>());
|
||||
CHECK(uarg{PRV_PTR()}.can_cast_to<const A* const>());
|
||||
CHECK(uarg{r, PRV_PTR()}.can_cast_to<A*>(r));
|
||||
CHECK(uarg{r, PRV_PTR()}.can_cast_to<A* const>(r));
|
||||
CHECK(uarg{r, PRV_PTR()}.can_cast_to<const A*>(r));
|
||||
CHECK(uarg{r, PRV_PTR()}.can_cast_to<const A* const>(r));
|
||||
|
||||
CHECK(uarg{PRV_PTR()}.cast<A*>()->f() == 1);
|
||||
CHECK(uarg{PRV_PTR()}.cast<A* const>()->f() == 1);
|
||||
CHECK(uarg{PRV_PTR()}.cast<const A*>()->f() == 1);
|
||||
CHECK(uarg{PRV_PTR()}.cast<const A* const>()->f() == 1);
|
||||
CHECK(uarg{r, PRV_PTR()}.cast<A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, PRV_PTR()}.cast<A* const>(r)->f() == 1);
|
||||
CHECK(uarg{r, PRV_PTR()}.cast<const A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, PRV_PTR()}.cast<const A* const>(r)->f() == 1);
|
||||
}
|
||||
|
||||
SUBCASE("PRV_CPTR") {
|
||||
CHECK_FALSE(uarg{PRV_CPTR()}.can_cast_to<A*>());
|
||||
CHECK_FALSE(uarg{PRV_CPTR()}.can_cast_to<A* const>());
|
||||
CHECK(uarg{PRV_CPTR()}.can_cast_to<const A*>());
|
||||
CHECK(uarg{PRV_CPTR()}.can_cast_to<const A* const>());
|
||||
CHECK_FALSE(uarg{r, PRV_CPTR()}.can_cast_to<A*>(r));
|
||||
CHECK_FALSE(uarg{r, PRV_CPTR()}.can_cast_to<A* const>(r));
|
||||
CHECK(uarg{r, PRV_CPTR()}.can_cast_to<const A*>(r));
|
||||
CHECK(uarg{r, PRV_CPTR()}.can_cast_to<const A* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{PRV_CPTR()}.cast<A*>());
|
||||
// CHECK_THROWS(std::ignore = uarg{PRV_CPTR()}.cast<A* const>());
|
||||
CHECK(uarg{PRV_CPTR()}.cast<const A*>()->f() == 1);
|
||||
CHECK(uarg{PRV_CPTR()}.cast<const A* const>()->f() == 1);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, PRV_CPTR()}.cast<A*>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, PRV_CPTR()}.cast<A* const>(r));
|
||||
CHECK(uarg{r, PRV_CPTR()}.cast<const A*>(r)->f() == 1);
|
||||
CHECK(uarg{r, PRV_CPTR()}.cast<const A* const>(r)->f() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ TEST_CASE("meta/meta_utilities/arg3") {
|
||||
TEST_CASE("meta/meta_utilities/arg3/cast") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
auto LV = []() -> D& { static D v; return v; };
|
||||
auto CLV = []() -> const D& { static D v; return v; };
|
||||
@@ -79,50 +81,50 @@ TEST_CASE("meta/meta_utilities/arg3/cast") {
|
||||
// *------------------------------------------------------------*
|
||||
|
||||
SUBCASE("LV") {
|
||||
CHECK_FALSE(uarg{LV()}.can_cast_to<A>());
|
||||
CHECK_FALSE(uarg{LV()}.can_cast_to<const A>());
|
||||
CHECK_FALSE(uarg{r, LV()}.can_cast_to<A>(r));
|
||||
CHECK_FALSE(uarg{r, LV()}.can_cast_to<const A>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{LV()}.cast<A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{LV()}.cast<const A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{r, LV()}.cast<A>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, LV()}.cast<const A>(r));
|
||||
}
|
||||
|
||||
SUBCASE("CLV") {
|
||||
CHECK_FALSE(uarg{CLV()}.can_cast_to<A>());
|
||||
CHECK_FALSE(uarg{CLV()}.can_cast_to<const A>());
|
||||
CHECK_FALSE(uarg{r, CLV()}.can_cast_to<A>(r));
|
||||
CHECK_FALSE(uarg{r, CLV()}.can_cast_to<const A>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{CLV()}.cast<A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{CLV()}.cast<const A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CLV()}.cast<A>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CLV()}.cast<const A>(r));
|
||||
}
|
||||
|
||||
SUBCASE("XV") {
|
||||
CHECK_FALSE(uarg{XV()}.can_cast_to<A>());
|
||||
CHECK_FALSE(uarg{XV()}.can_cast_to<const A>());
|
||||
CHECK_FALSE(uarg{r, XV()}.can_cast_to<A>(r));
|
||||
CHECK_FALSE(uarg{r, XV()}.can_cast_to<const A>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{XV()}.cast<A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{XV()}.cast<const A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{r, XV()}.cast<A>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, XV()}.cast<const A>(r));
|
||||
}
|
||||
|
||||
SUBCASE("CXV") {
|
||||
CHECK_FALSE(uarg{CXV()}.can_cast_to<A>());
|
||||
CHECK_FALSE(uarg{CXV()}.can_cast_to<const A>());
|
||||
CHECK_FALSE(uarg{r, CXV()}.can_cast_to<A>(r));
|
||||
CHECK_FALSE(uarg{r, CXV()}.can_cast_to<const A>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{CXV()}.cast<A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{CXV()}.cast<const A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CXV()}.cast<A>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CXV()}.cast<const A>(r));
|
||||
}
|
||||
|
||||
SUBCASE("PRV") {
|
||||
CHECK_FALSE(uarg{PRV()}.can_cast_to<A>());
|
||||
CHECK_FALSE(uarg{PRV()}.can_cast_to<const A>());
|
||||
CHECK_FALSE(uarg{r, PRV()}.can_cast_to<A>(r));
|
||||
CHECK_FALSE(uarg{r, PRV()}.can_cast_to<const A>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{PRV()}.cast<A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{PRV()}.cast<const A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{r, PRV()}.cast<A>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, PRV()}.cast<const A>(r));
|
||||
}
|
||||
|
||||
SUBCASE("CPRV") {
|
||||
CHECK_FALSE(uarg{CPRV()}.can_cast_to<A>());
|
||||
CHECK_FALSE(uarg{CPRV()}.can_cast_to<const A>());
|
||||
CHECK_FALSE(uarg{r, CPRV()}.can_cast_to<A>(r));
|
||||
CHECK_FALSE(uarg{r, CPRV()}.can_cast_to<const A>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{CPRV()}.cast<A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{CPRV()}.cast<const A>());
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CPRV()}.cast<A>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CPRV()}.cast<const A>(r));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
TEST_CASE("meta/meta_utilities/arg4/cast") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
auto LV_PTR = []() -> int*& { static int v{42}; static int* p{&v}; return p; };
|
||||
auto CLV_PTR = []() -> int* const& { static int v{42}; static int* p{&v}; return p; };
|
||||
@@ -24,122 +26,122 @@ TEST_CASE("meta/meta_utilities/arg4/cast") {
|
||||
auto PRV_CPTR = []() -> const int* { static int v{42}; static const int* p{&v}; return p; };
|
||||
|
||||
SUBCASE("LV_PTR") {
|
||||
CHECK(uarg{LV_PTR()}.can_cast_to<int*>());
|
||||
CHECK(uarg{LV_PTR()}.can_cast_to<int* const>());
|
||||
CHECK(uarg{LV_PTR()}.can_cast_to<const int*>());
|
||||
CHECK(uarg{LV_PTR()}.can_cast_to<const int* const>());
|
||||
CHECK(uarg{r, LV_PTR()}.can_cast_to<int*>(r));
|
||||
CHECK(uarg{r, LV_PTR()}.can_cast_to<int* const>(r));
|
||||
CHECK(uarg{r, LV_PTR()}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, LV_PTR()}.can_cast_to<const int* const>(r));
|
||||
|
||||
CHECK(*uarg{LV_PTR()}.cast<int*>() == 42);
|
||||
CHECK(*uarg{LV_PTR()}.cast<int* const>() == 42);
|
||||
CHECK(*uarg{LV_PTR()}.cast<const int*>() == 42);
|
||||
CHECK(*uarg{LV_PTR()}.cast<const int* const>() == 42);
|
||||
CHECK(*uarg{r, LV_PTR()}.cast<int*>(r) == 42);
|
||||
CHECK(*uarg{r, LV_PTR()}.cast<int* const>(r) == 42);
|
||||
CHECK(*uarg{r, LV_PTR()}.cast<const int*>(r) == 42);
|
||||
CHECK(*uarg{r, LV_PTR()}.cast<const int* const>(r) == 42);
|
||||
}
|
||||
|
||||
SUBCASE("CLV_PTR") {
|
||||
CHECK(uarg{CLV_PTR()}.can_cast_to<int*>());
|
||||
CHECK(uarg{CLV_PTR()}.can_cast_to<int* const>());
|
||||
CHECK(uarg{CLV_PTR()}.can_cast_to<const int*>());
|
||||
CHECK(uarg{CLV_PTR()}.can_cast_to<const int* const>());
|
||||
CHECK(uarg{r, CLV_PTR()}.can_cast_to<int*>(r));
|
||||
CHECK(uarg{r, CLV_PTR()}.can_cast_to<int* const>(r));
|
||||
CHECK(uarg{r, CLV_PTR()}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, CLV_PTR()}.can_cast_to<const int* const>(r));
|
||||
|
||||
CHECK(*uarg{CLV_PTR()}.cast<int*>() == 42);
|
||||
CHECK(*uarg{CLV_PTR()}.cast<int* const>() == 42);
|
||||
CHECK(*uarg{CLV_PTR()}.cast<const int*>() == 42);
|
||||
CHECK(*uarg{CLV_PTR()}.cast<const int* const>() == 42);
|
||||
CHECK(*uarg{r, CLV_PTR()}.cast<int*>(r) == 42);
|
||||
CHECK(*uarg{r, CLV_PTR()}.cast<int* const>(r) == 42);
|
||||
CHECK(*uarg{r, CLV_PTR()}.cast<const int*>(r) == 42);
|
||||
CHECK(*uarg{r, CLV_PTR()}.cast<const int* const>(r) == 42);
|
||||
}
|
||||
|
||||
SUBCASE("XV_PTR") {
|
||||
CHECK(uarg{XV_PTR()}.can_cast_to<int*>());
|
||||
CHECK(uarg{XV_PTR()}.can_cast_to<int* const>());
|
||||
CHECK(uarg{XV_PTR()}.can_cast_to<const int*>());
|
||||
CHECK(uarg{XV_PTR()}.can_cast_to<const int* const>());
|
||||
CHECK(uarg{r, XV_PTR()}.can_cast_to<int*>(r));
|
||||
CHECK(uarg{r, XV_PTR()}.can_cast_to<int* const>(r));
|
||||
CHECK(uarg{r, XV_PTR()}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, XV_PTR()}.can_cast_to<const int* const>(r));
|
||||
|
||||
CHECK(*uarg{XV_PTR()}.cast<int*>() == 42);
|
||||
CHECK(*uarg{XV_PTR()}.cast<int* const>() == 42);
|
||||
CHECK(*uarg{XV_PTR()}.cast<const int*>() == 42);
|
||||
CHECK(*uarg{XV_PTR()}.cast<const int* const>() == 42);
|
||||
CHECK(*uarg{r, XV_PTR()}.cast<int*>(r) == 42);
|
||||
CHECK(*uarg{r, XV_PTR()}.cast<int* const>(r) == 42);
|
||||
CHECK(*uarg{r, XV_PTR()}.cast<const int*>(r) == 42);
|
||||
CHECK(*uarg{r, XV_PTR()}.cast<const int* const>(r) == 42);
|
||||
}
|
||||
|
||||
SUBCASE("CXV_PTR") {
|
||||
CHECK(uarg{CXV_PTR()}.can_cast_to<int*>());
|
||||
CHECK(uarg{CXV_PTR()}.can_cast_to<int* const>());
|
||||
CHECK(uarg{CXV_PTR()}.can_cast_to<const int*>());
|
||||
CHECK(uarg{CXV_PTR()}.can_cast_to<const int* const>());
|
||||
CHECK(uarg{r, CXV_PTR()}.can_cast_to<int*>(r));
|
||||
CHECK(uarg{r, CXV_PTR()}.can_cast_to<int* const>(r));
|
||||
CHECK(uarg{r, CXV_PTR()}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, CXV_PTR()}.can_cast_to<const int* const>(r));
|
||||
|
||||
CHECK(*uarg{CXV_PTR()}.cast<int*>() == 42);
|
||||
CHECK(*uarg{CXV_PTR()}.cast<int* const>() == 42);
|
||||
CHECK(*uarg{CXV_PTR()}.cast<const int*>() == 42);
|
||||
CHECK(*uarg{CXV_PTR()}.cast<const int* const>() == 42);
|
||||
CHECK(*uarg{r, CXV_PTR()}.cast<int*>(r) == 42);
|
||||
CHECK(*uarg{r, CXV_PTR()}.cast<int* const>(r) == 42);
|
||||
CHECK(*uarg{r, CXV_PTR()}.cast<const int*>(r) == 42);
|
||||
CHECK(*uarg{r, CXV_PTR()}.cast<const int* const>(r) == 42);
|
||||
}
|
||||
|
||||
SUBCASE("PRV_PTR") {
|
||||
CHECK(uarg{PRV_PTR()}.can_cast_to<int*>());
|
||||
CHECK(uarg{PRV_PTR()}.can_cast_to<int* const>());
|
||||
CHECK(uarg{PRV_PTR()}.can_cast_to<const int*>());
|
||||
CHECK(uarg{PRV_PTR()}.can_cast_to<const int* const>());
|
||||
CHECK(uarg{r, PRV_PTR()}.can_cast_to<int*>(r));
|
||||
CHECK(uarg{r, PRV_PTR()}.can_cast_to<int* const>(r));
|
||||
CHECK(uarg{r, PRV_PTR()}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, PRV_PTR()}.can_cast_to<const int* const>(r));
|
||||
|
||||
CHECK(*uarg{PRV_PTR()}.cast<int*>() == 42);
|
||||
CHECK(*uarg{PRV_PTR()}.cast<int* const>() == 42);
|
||||
CHECK(*uarg{PRV_PTR()}.cast<const int*>() == 42);
|
||||
CHECK(*uarg{PRV_PTR()}.cast<const int* const>() == 42);
|
||||
CHECK(*uarg{r, PRV_PTR()}.cast<int*>(r) == 42);
|
||||
CHECK(*uarg{r, PRV_PTR()}.cast<int* const>(r) == 42);
|
||||
CHECK(*uarg{r, PRV_PTR()}.cast<const int*>(r) == 42);
|
||||
CHECK(*uarg{r, PRV_PTR()}.cast<const int* const>(r) == 42);
|
||||
}
|
||||
|
||||
SUBCASE("LV_CPTR") {
|
||||
CHECK_FALSE(uarg{LV_CPTR()}.can_cast_to<int*>());
|
||||
CHECK_FALSE(uarg{LV_CPTR()}.can_cast_to<int* const>());
|
||||
CHECK(uarg{LV_CPTR()}.can_cast_to<const int*>());
|
||||
CHECK(uarg{LV_CPTR()}.can_cast_to<const int* const>());
|
||||
CHECK_FALSE(uarg{r, LV_CPTR()}.can_cast_to<int*>(r));
|
||||
CHECK_FALSE(uarg{r, LV_CPTR()}.can_cast_to<int* const>(r));
|
||||
CHECK(uarg{r, LV_CPTR()}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, LV_CPTR()}.can_cast_to<const int* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{LV_CPTR()}.cast<int*>());
|
||||
// CHECK_THROWS(std::ignore = uarg{LV_CPTR()}.cast<int* const>());
|
||||
CHECK(*uarg{LV_CPTR()}.cast<const int*>() == 42);
|
||||
CHECK(*uarg{LV_CPTR()}.cast<const int* const>() == 42);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, LV_CPTR()}.cast<int*>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, LV_CPTR()}.cast<int* const>(r));
|
||||
CHECK(*uarg{r, LV_CPTR()}.cast<const int*>(r) == 42);
|
||||
CHECK(*uarg{r, LV_CPTR()}.cast<const int* const>(r) == 42);
|
||||
}
|
||||
|
||||
SUBCASE("CLV_CPTR") {
|
||||
CHECK_FALSE(uarg{CLV_CPTR()}.can_cast_to<int*>());
|
||||
CHECK_FALSE(uarg{CLV_CPTR()}.can_cast_to<int* const>());
|
||||
CHECK(uarg{CLV_CPTR()}.can_cast_to<const int*>());
|
||||
CHECK(uarg{CLV_CPTR()}.can_cast_to<const int* const>());
|
||||
CHECK_FALSE(uarg{r, CLV_CPTR()}.can_cast_to<int*>(r));
|
||||
CHECK_FALSE(uarg{r, CLV_CPTR()}.can_cast_to<int* const>(r));
|
||||
CHECK(uarg{r, CLV_CPTR()}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, CLV_CPTR()}.can_cast_to<const int* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{CLV_CPTR()}.cast<int*>());
|
||||
// CHECK_THROWS(std::ignore = uarg{CLV_CPTR()}.cast<int* const>());
|
||||
CHECK(*uarg{CLV_CPTR()}.cast<const int*>() == 42);
|
||||
CHECK(*uarg{CLV_CPTR()}.cast<const int* const>() == 42);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CLV_CPTR()}.cast<int*>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CLV_CPTR()}.cast<int* const>(r));
|
||||
CHECK(*uarg{r, CLV_CPTR()}.cast<const int*>(r) == 42);
|
||||
CHECK(*uarg{r, CLV_CPTR()}.cast<const int* const>(r) == 42);
|
||||
}
|
||||
|
||||
SUBCASE("XV_CPTR") {
|
||||
CHECK_FALSE(uarg{XV_CPTR()}.can_cast_to<int*>());
|
||||
CHECK_FALSE(uarg{XV_CPTR()}.can_cast_to<int* const>());
|
||||
CHECK(uarg{XV_CPTR()}.can_cast_to<const int*>());
|
||||
CHECK(uarg{XV_CPTR()}.can_cast_to<const int* const>());
|
||||
CHECK_FALSE(uarg{r, XV_CPTR()}.can_cast_to<int*>(r));
|
||||
CHECK_FALSE(uarg{r, XV_CPTR()}.can_cast_to<int* const>(r));
|
||||
CHECK(uarg{r, XV_CPTR()}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, XV_CPTR()}.can_cast_to<const int* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{XV_CPTR()}.cast<int*>());
|
||||
// CHECK_THROWS(std::ignore = uarg{XV_CPTR()}.cast<int* const>());
|
||||
CHECK(*uarg{XV_CPTR()}.cast<const int*>() == 42);
|
||||
CHECK(*uarg{XV_CPTR()}.cast<const int* const>() == 42);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, XV_CPTR()}.cast<int*>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, XV_CPTR()}.cast<int* const>(r));
|
||||
CHECK(*uarg{r, XV_CPTR()}.cast<const int*>(r) == 42);
|
||||
CHECK(*uarg{r, XV_CPTR()}.cast<const int* const>(r) == 42);
|
||||
}
|
||||
|
||||
SUBCASE("CXV_CPTR") {
|
||||
CHECK_FALSE(uarg{CXV_CPTR()}.can_cast_to<int*>());
|
||||
CHECK_FALSE(uarg{CXV_CPTR()}.can_cast_to<int* const>());
|
||||
CHECK(uarg{CXV_CPTR()}.can_cast_to<const int*>());
|
||||
CHECK(uarg{CXV_CPTR()}.can_cast_to<const int* const>());
|
||||
CHECK_FALSE(uarg{r, CXV_CPTR()}.can_cast_to<int*>(r));
|
||||
CHECK_FALSE(uarg{r, CXV_CPTR()}.can_cast_to<int* const>(r));
|
||||
CHECK(uarg{r, CXV_CPTR()}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, CXV_CPTR()}.can_cast_to<const int* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{CXV_CPTR()}.cast<int*>());
|
||||
// CHECK_THROWS(std::ignore = uarg{CXV_CPTR()}.cast<int* const>());
|
||||
CHECK(*uarg{CXV_CPTR()}.cast<const int*>() == 42);
|
||||
CHECK(*uarg{CXV_CPTR()}.cast<const int* const>() == 42);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CXV_CPTR()}.cast<int*>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, CXV_CPTR()}.cast<int* const>(r));
|
||||
CHECK(*uarg{r, CXV_CPTR()}.cast<const int*>(r) == 42);
|
||||
CHECK(*uarg{r, CXV_CPTR()}.cast<const int* const>(r) == 42);
|
||||
}
|
||||
|
||||
SUBCASE("PRV_CPTR") {
|
||||
CHECK_FALSE(uarg{PRV_CPTR()}.can_cast_to<int*>());
|
||||
CHECK_FALSE(uarg{PRV_CPTR()}.can_cast_to<int* const>());
|
||||
CHECK(uarg{PRV_CPTR()}.can_cast_to<const int*>());
|
||||
CHECK(uarg{PRV_CPTR()}.can_cast_to<const int* const>());
|
||||
CHECK_FALSE(uarg{r, PRV_CPTR()}.can_cast_to<int*>(r));
|
||||
CHECK_FALSE(uarg{r, PRV_CPTR()}.can_cast_to<int* const>(r));
|
||||
CHECK(uarg{r, PRV_CPTR()}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, PRV_CPTR()}.can_cast_to<const int* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{PRV_CPTR()}.cast<int*>());
|
||||
// CHECK_THROWS(std::ignore = uarg{PRV_CPTR()}.cast<int* const>());
|
||||
CHECK(*uarg{PRV_CPTR()}.cast<const int*>() == 42);
|
||||
CHECK(*uarg{PRV_CPTR()}.cast<const int* const>() == 42);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, PRV_CPTR()}.cast<int*>(r));
|
||||
// CHECK_THROWS(std::ignore = uarg{r, PRV_CPTR()}.cast<int* const>(r));
|
||||
CHECK(*uarg{r, PRV_CPTR()}.cast<const int*>(r) == 42);
|
||||
CHECK(*uarg{r, PRV_CPTR()}.cast<const int* const>(r) == 42);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,85 +50,87 @@ TEST_CASE("meta/meta_utilities/arg5") {
|
||||
TEST_CASE("meta/meta_utilities/arg5/cast") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
SUBCASE("int[2]") {
|
||||
int arr[2]{1,2};
|
||||
CHECK(uarg(arr).get_raw_type() == meta::resolve_type(arr));
|
||||
CHECK(uarg(r, arr).get_raw_type() == meta::resolve_type(arr));
|
||||
|
||||
static_assert(std::is_invocable_v<void(int*), int (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const int*), int (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(int* const), int (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const int* const), int (&) [2]>);
|
||||
|
||||
CHECK(uarg(arr).can_cast_to<int*>());
|
||||
CHECK(uarg(arr).can_cast_to<const int*>());
|
||||
CHECK(uarg(arr).can_cast_to<int* const>());
|
||||
CHECK(uarg(arr).can_cast_to<const int* const>());
|
||||
CHECK(uarg(r, arr).can_cast_to<int*>(r));
|
||||
CHECK(uarg(r, arr).can_cast_to<const int*>(r));
|
||||
CHECK(uarg(r, arr).can_cast_to<int* const>(r));
|
||||
CHECK(uarg(r, arr).can_cast_to<const int* const>(r));
|
||||
|
||||
CHECK(uarg(arr).cast<int*>() == static_cast<int*>(arr));
|
||||
CHECK(uarg(arr).cast<const int*>() == static_cast<const int*>(arr));
|
||||
CHECK(uarg(arr).cast<int* const>() == static_cast<int*>(arr));
|
||||
CHECK(uarg(arr).cast<const int* const>() == static_cast<const int*>(arr));
|
||||
CHECK(uarg(r, arr).cast<int*>(r) == static_cast<int*>(arr));
|
||||
CHECK(uarg(r, arr).cast<const int*>(r) == static_cast<const int*>(arr));
|
||||
CHECK(uarg(r, arr).cast<int* const>(r) == static_cast<int*>(arr));
|
||||
CHECK(uarg(r, arr).cast<const int* const>(r) == static_cast<const int*>(arr));
|
||||
}
|
||||
|
||||
SUBCASE("const int[2]") {
|
||||
const int arr[2]{1,2};
|
||||
CHECK(uarg(arr).get_raw_type() == meta::resolve_type(arr));
|
||||
CHECK(uarg(r, arr).get_raw_type() == meta::resolve_type(arr));
|
||||
|
||||
static_assert(!std::is_invocable_v<void(int*), const int (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const int*), const int (&) [2]>);
|
||||
static_assert(!std::is_invocable_v<void(int* const), const int (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const int* const), const int (&) [2]>);
|
||||
|
||||
CHECK_FALSE(uarg(arr).can_cast_to<int*>());
|
||||
CHECK(uarg(arr).can_cast_to<const int*>());
|
||||
CHECK_FALSE(uarg(arr).can_cast_to<int* const>());
|
||||
CHECK(uarg(arr).can_cast_to<const int* const>());
|
||||
CHECK_FALSE(uarg(r, arr).can_cast_to<int*>(r));
|
||||
CHECK(uarg(r, arr).can_cast_to<const int*>(r));
|
||||
CHECK_FALSE(uarg(r, arr).can_cast_to<int* const>(r));
|
||||
CHECK(uarg(r, arr).can_cast_to<const int* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg(arr).cast<int*>());
|
||||
CHECK(uarg(arr).cast<const int*>() == static_cast<const int*>(arr));
|
||||
// CHECK_THROWS(std::ignore = uarg(arr).cast<int* const>());
|
||||
CHECK(uarg(arr).cast<const int* const>() == static_cast<const int*>(arr));
|
||||
// CHECK_THROWS(std::ignore = uarg(r, arr).cast<int*>(r));
|
||||
CHECK(uarg(r, arr).cast<const int*>(r) == static_cast<const int*>(arr));
|
||||
// CHECK_THROWS(std::ignore = uarg(r, arr).cast<int* const>(r));
|
||||
CHECK(uarg(r, arr).cast<const int* const>(r) == static_cast<const int*>(arr));
|
||||
}
|
||||
|
||||
SUBCASE("D[2]") {
|
||||
D arr[2];
|
||||
CHECK(uarg(arr).get_raw_type() == meta::resolve_type(arr));
|
||||
CHECK(uarg(r, arr).get_raw_type() == meta::resolve_type(arr));
|
||||
|
||||
static_assert(std::is_invocable_v<void(A*), D (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const A*), D (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(A* const), D (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const A* const), D (&) [2]>);
|
||||
|
||||
CHECK(uarg(arr).can_cast_to<A*>());
|
||||
CHECK(uarg(arr).can_cast_to<const A*>());
|
||||
CHECK(uarg(arr).can_cast_to<A* const>());
|
||||
CHECK(uarg(arr).can_cast_to<const A* const>());
|
||||
CHECK(uarg(r, arr).can_cast_to<A*>(r));
|
||||
CHECK(uarg(r, arr).can_cast_to<const A*>(r));
|
||||
CHECK(uarg(r, arr).can_cast_to<A* const>(r));
|
||||
CHECK(uarg(r, arr).can_cast_to<const A* const>(r));
|
||||
|
||||
CHECK(uarg(arr).cast<A*>() == static_cast<A*>(arr));
|
||||
CHECK(uarg(arr).cast<const A*>() == static_cast<const A*>(arr));
|
||||
CHECK(uarg(arr).cast<A* const>() == static_cast<A*>(arr));
|
||||
CHECK(uarg(arr).cast<const A* const>() == static_cast<const A*>(arr));
|
||||
CHECK(uarg(r, arr).cast<A*>(r) == static_cast<A*>(arr));
|
||||
CHECK(uarg(r, arr).cast<const A*>(r) == static_cast<const A*>(arr));
|
||||
CHECK(uarg(r, arr).cast<A* const>(r) == static_cast<A*>(arr));
|
||||
CHECK(uarg(r, arr).cast<const A* const>(r) == static_cast<const A*>(arr));
|
||||
}
|
||||
|
||||
SUBCASE("const D[2]") {
|
||||
const D arr[2];
|
||||
CHECK(uarg(arr).get_raw_type() == meta::resolve_type(arr));
|
||||
CHECK(uarg(r, arr).get_raw_type() == meta::resolve_type(arr));
|
||||
|
||||
static_assert(!std::is_invocable_v<void(A*), const D (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const A*), const D (&) [2]>);
|
||||
static_assert(!std::is_invocable_v<void(A* const), const D (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const A* const), const D (&) [2]>);
|
||||
|
||||
CHECK_FALSE(uarg(arr).can_cast_to<A*>());
|
||||
CHECK(uarg(arr).can_cast_to<const A*>());
|
||||
CHECK_FALSE(uarg(arr).can_cast_to<A* const>());
|
||||
CHECK(uarg(arr).can_cast_to<const A* const>());
|
||||
CHECK_FALSE(uarg(r, arr).can_cast_to<A*>(r));
|
||||
CHECK(uarg(r, arr).can_cast_to<const A*>(r));
|
||||
CHECK_FALSE(uarg(r, arr).can_cast_to<A* const>(r));
|
||||
CHECK(uarg(r, arr).can_cast_to<const A* const>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg(arr).cast<A*>());
|
||||
CHECK(uarg(arr).cast<const A*>() == static_cast<const A*>(arr));
|
||||
// CHECK_THROWS(std::ignore = uarg(arr).cast<A* const>());
|
||||
CHECK(uarg(arr).cast<const A* const>() == static_cast<const A*>(arr));
|
||||
// CHECK_THROWS(std::ignore = uarg(r, arr).cast<A*>(r));
|
||||
CHECK(uarg(r, arr).cast<const A*>(r) == static_cast<const A*>(arr));
|
||||
// CHECK_THROWS(std::ignore = uarg(r, arr).cast<A* const>(r));
|
||||
CHECK(uarg(r, arr).cast<const A* const>(r) == static_cast<const A*>(arr));
|
||||
}
|
||||
|
||||
SUBCASE("&") {
|
||||
@@ -137,7 +139,7 @@ TEST_CASE("meta/meta_utilities/arg5/cast") {
|
||||
|
||||
{
|
||||
auto LV = []() -> T& { return src; };
|
||||
CHECK(uarg{LV()}.get_raw_type() == meta::resolve_type<D[2]>());
|
||||
CHECK(uarg{r, LV()}.get_raw_type() == meta::resolve_type<D[2]>());
|
||||
|
||||
static_assert(std::is_invocable_v<void(A*), decltype(LV())>);
|
||||
static_assert(std::is_invocable_v<void(const A*), decltype(LV())>);
|
||||
@@ -149,55 +151,55 @@ TEST_CASE("meta/meta_utilities/arg5/cast") {
|
||||
[](A* const){}(LV());
|
||||
[](const A* const){}(LV());
|
||||
|
||||
CHECK(uarg(LV()).cast<A*>() == static_cast<A*>(src));
|
||||
CHECK(uarg(LV()).cast<const A*>() == static_cast<const A*>(src));
|
||||
CHECK(uarg(LV()).cast<A* const>() == static_cast<A*>(src));
|
||||
CHECK(uarg(LV()).cast<const A* const>() == static_cast<const A*>(src));
|
||||
CHECK(uarg(r, LV()).cast<A*>(r) == static_cast<A*>(src));
|
||||
CHECK(uarg(r, LV()).cast<const A*>(r) == static_cast<const A*>(src));
|
||||
CHECK(uarg(r, LV()).cast<A* const>(r) == static_cast<A*>(src));
|
||||
CHECK(uarg(r, LV()).cast<const A* const>(r) == static_cast<const A*>(src));
|
||||
}
|
||||
|
||||
{
|
||||
auto CLV = []() -> const T& { return src; };
|
||||
CHECK(uarg{CLV()}.get_raw_type() == meta::resolve_type<D[2]>());
|
||||
CHECK(uarg{r, CLV()}.get_raw_type() == meta::resolve_type<D[2]>());
|
||||
|
||||
static_assert(!std::is_invocable_v<void(A*), decltype(CLV())>);
|
||||
static_assert(std::is_invocable_v<void(const A*), decltype(CLV())>);
|
||||
static_assert(!std::is_invocable_v<void(A* const), decltype(CLV())>);
|
||||
static_assert(std::is_invocable_v<void(const A* const), decltype(CLV())>);
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg(CLV()).cast<A*>());
|
||||
CHECK(uarg(CLV()).cast<const A*>() == static_cast<const A*>(src));
|
||||
// CHECK_THROWS(std::ignore = uarg(CLV()).cast<A* const>());
|
||||
CHECK(uarg(CLV()).cast<const A* const>() == static_cast<const A*>(src));
|
||||
// CHECK_THROWS(std::ignore = uarg(r, CLV()).cast<A*>(r));
|
||||
CHECK(uarg(r, CLV()).cast<const A*>(r) == static_cast<const A*>(src));
|
||||
// CHECK_THROWS(std::ignore = uarg(r, CLV()).cast<A* const>(r));
|
||||
CHECK(uarg(r, CLV()).cast<const A* const>(r) == static_cast<const A*>(src));
|
||||
}
|
||||
|
||||
{
|
||||
auto XV = []() -> T&& { return std::move(src); };
|
||||
CHECK(uarg{XV()}.get_raw_type() == meta::resolve_type<D[2]>());
|
||||
CHECK(uarg{r, XV()}.get_raw_type() == meta::resolve_type<D[2]>());
|
||||
|
||||
static_assert(std::is_invocable_v<void(A*), decltype(XV())>);
|
||||
static_assert(std::is_invocable_v<void(const A*), decltype(XV())>);
|
||||
static_assert(std::is_invocable_v<void(A* const), decltype(XV())>);
|
||||
static_assert(std::is_invocable_v<void(const A* const), decltype(XV())>);
|
||||
|
||||
CHECK(uarg(XV()).cast<A*>() == static_cast<A*>(src));
|
||||
CHECK(uarg(XV()).cast<const A*>() == static_cast<const A*>(src));
|
||||
CHECK(uarg(XV()).cast<A* const>() == static_cast<A*>(src));
|
||||
CHECK(uarg(XV()).cast<const A* const>() == static_cast<const A*>(src));
|
||||
CHECK(uarg(r, XV()).cast<A*>(r) == static_cast<A*>(src));
|
||||
CHECK(uarg(r, XV()).cast<const A*>(r) == static_cast<const A*>(src));
|
||||
CHECK(uarg(r, XV()).cast<A* const>(r) == static_cast<A*>(src));
|
||||
CHECK(uarg(r, XV()).cast<const A* const>(r) == static_cast<const A*>(src));
|
||||
}
|
||||
|
||||
{
|
||||
auto CXV = []() -> const T&& { return std::move(src); };
|
||||
CHECK(uarg{CXV()}.get_raw_type() == meta::resolve_type<D[2]>());
|
||||
CHECK(uarg{r, CXV()}.get_raw_type() == meta::resolve_type<D[2]>());
|
||||
|
||||
static_assert(!std::is_invocable_v<void(A*), decltype(CXV())>);
|
||||
static_assert(std::is_invocable_v<void(const A*), decltype(CXV())>);
|
||||
static_assert(!std::is_invocable_v<void(A* const), decltype(CXV())>);
|
||||
static_assert(std::is_invocable_v<void(const A* const), decltype(CXV())>);
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg(CXV()).cast<A*>());
|
||||
CHECK(uarg(CXV()).cast<const A*>() == static_cast<const A*>(src));
|
||||
// CHECK_THROWS(std::ignore = uarg(CXV()).cast<A* const>());
|
||||
CHECK(uarg(CXV()).cast<const A* const>() == static_cast<const A*>(src));
|
||||
// CHECK_THROWS(std::ignore = uarg(r, CXV()).cast<A*>(r));
|
||||
CHECK(uarg(r, CXV()).cast<const A*>(r) == static_cast<const A*>(src));
|
||||
// CHECK_THROWS(std::ignore = uarg(r, CXV()).cast<A* const>(r));
|
||||
CHECK(uarg(r, CXV()).cast<const A* const>(r) == static_cast<const A*>(src));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,19 +214,19 @@ TEST_CASE("meta/meta_utilities/arg5/cast") {
|
||||
static_assert(std::is_invocable_v<void(D (* const) [2]), D (*) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const D (* const) [2]), D (*) [2]>);
|
||||
|
||||
CHECK(uarg{arr}.can_cast_to<D (&) [2]>());
|
||||
CHECK(uarg{arr}.can_cast_to<const D (&) [2]>());
|
||||
CHECK(uarg{&arr}.can_cast_to<D (*) [2]>());
|
||||
CHECK(uarg{&arr}.can_cast_to<const D (*) [2]>());
|
||||
CHECK(uarg{&arr}.can_cast_to<D (* const) [2]>());
|
||||
CHECK(uarg{&arr}.can_cast_to<const D (* const) [2]>());
|
||||
CHECK(uarg{r, arr}.can_cast_to<D (&) [2]>(r));
|
||||
CHECK(uarg{r, arr}.can_cast_to<const D (&) [2]>(r));
|
||||
CHECK(uarg{r, &arr}.can_cast_to<D (*) [2]>(r));
|
||||
CHECK(uarg{r, &arr}.can_cast_to<const D (*) [2]>(r));
|
||||
CHECK(uarg{r, &arr}.can_cast_to<D (* const) [2]>(r));
|
||||
CHECK(uarg{r, &arr}.can_cast_to<const D (* const) [2]>(r));
|
||||
|
||||
CHECK(&uarg{arr}.cast<D (&) [2]>() == &arr);
|
||||
CHECK(&uarg{arr}.cast<const D (&) [2]>() == &arr);
|
||||
CHECK(uarg{&arr}.cast<D (*) [2]>() == &arr);
|
||||
CHECK(uarg{&arr}.cast<const D (*) [2]>() == &arr);
|
||||
CHECK(uarg{&arr}.cast<D (* const) [2]>() == &arr);
|
||||
CHECK(uarg{&arr}.cast<const D (* const) [2]>() == &arr);
|
||||
CHECK(&uarg{r, arr}.cast<D (&) [2]>(r) == &arr);
|
||||
CHECK(&uarg{r, arr}.cast<const D (&) [2]>(r) == &arr);
|
||||
CHECK(uarg{r, &arr}.cast<D (*) [2]>(r) == &arr);
|
||||
CHECK(uarg{r, &arr}.cast<const D (*) [2]>(r) == &arr);
|
||||
CHECK(uarg{r, &arr}.cast<D (* const) [2]>(r) == &arr);
|
||||
CHECK(uarg{r, &arr}.cast<const D (* const) [2]>(r) == &arr);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -237,19 +239,19 @@ TEST_CASE("meta/meta_utilities/arg5/cast") {
|
||||
static_assert(!std::is_invocable_v<void(D (* const) [2]), const D (*) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const D (* const) [2]), const D (*) [2]>);
|
||||
|
||||
CHECK_FALSE(uarg{arr}.can_cast_to<D (&) [2]>());
|
||||
CHECK(uarg{arr}.can_cast_to<const D (&) [2]>());
|
||||
CHECK_FALSE(uarg{&arr}.can_cast_to<D (*) [2]>());
|
||||
CHECK(uarg{&arr}.can_cast_to<const D (*) [2]>());
|
||||
CHECK_FALSE(uarg{&arr}.can_cast_to<D (* const) [2]>());
|
||||
CHECK(uarg{&arr}.can_cast_to<const D (* const) [2]>());
|
||||
CHECK_FALSE(uarg{r, arr}.can_cast_to<D (&) [2]>(r));
|
||||
CHECK(uarg{r, arr}.can_cast_to<const D (&) [2]>(r));
|
||||
CHECK_FALSE(uarg{r, &arr}.can_cast_to<D (*) [2]>(r));
|
||||
CHECK(uarg{r, &arr}.can_cast_to<const D (*) [2]>(r));
|
||||
CHECK_FALSE(uarg{r, &arr}.can_cast_to<D (* const) [2]>(r));
|
||||
CHECK(uarg{r, &arr}.can_cast_to<const D (* const) [2]>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = &uarg{arr}.cast<D (&) [2]>());
|
||||
CHECK(&uarg{arr}.cast<const D (&) [2]>() == &arr);
|
||||
// CHECK_THROWS(std::ignore = uarg{&arr}.cast<D (*) [2]>());
|
||||
CHECK(uarg{&arr}.cast<const D (*) [2]>() == &arr);
|
||||
// CHECK_THROWS(std::ignore = uarg{&arr}.cast<D (* const) [2]>());
|
||||
CHECK(uarg{&arr}.cast<const D (* const) [2]>() == &arr);
|
||||
// CHECK_THROWS(std::ignore = &uarg{r, arr}.cast<D (&) [2]>(r));
|
||||
CHECK(&uarg{r, arr}.cast<const D (&) [2]>(r) == &arr);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, &arr}.cast<D (*) [2]>(r));
|
||||
CHECK(uarg{r, &arr}.cast<const D (*) [2]>(r) == &arr);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, &arr}.cast<D (* const) [2]>(r));
|
||||
CHECK(uarg{r, &arr}.cast<const D (* const) [2]>(r) == &arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ TEST_CASE("meta/meta_utilities/arg7") {
|
||||
TEST_CASE("meta/meta_utilities/arg7/cast/to_void") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
SUBCASE("int* -> void*") {
|
||||
int i{42};
|
||||
@@ -57,11 +59,11 @@ TEST_CASE("meta/meta_utilities/arg7/cast/to_void") {
|
||||
static_assert(std::is_invocable_v<void(void*), int*>);
|
||||
static_assert(std::is_invocable_v<void(const void*), int*>);
|
||||
|
||||
CHECK(uarg{&i}.can_cast_to<void*>());
|
||||
CHECK(uarg{&i}.can_cast_to<const void*>());
|
||||
CHECK(uarg{r, &i}.can_cast_to<void*>(r));
|
||||
CHECK(uarg{r, &i}.can_cast_to<const void*>(r));
|
||||
|
||||
CHECK(uarg{&i}.cast<void*>() == &i);
|
||||
CHECK(uarg{&i}.cast<const void*>() == &i);
|
||||
CHECK(uarg{r, &i}.cast<void*>(r) == &i);
|
||||
CHECK(uarg{r, &i}.cast<const void*>(r) == &i);
|
||||
}
|
||||
|
||||
SUBCASE("const int* -> void*") {
|
||||
@@ -70,11 +72,11 @@ TEST_CASE("meta/meta_utilities/arg7/cast/to_void") {
|
||||
static_assert(!std::is_invocable_v<void(void*), const int*>);
|
||||
static_assert(std::is_invocable_v<void(const void*), const int*>);
|
||||
|
||||
CHECK_FALSE(uarg{&i}.can_cast_to<void*>());
|
||||
CHECK(uarg{&i}.can_cast_to<const void*>());
|
||||
CHECK_FALSE(uarg{r, &i}.can_cast_to<void*>(r));
|
||||
CHECK(uarg{r, &i}.can_cast_to<const void*>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{&i}.cast<void*>());
|
||||
CHECK(uarg{&i}.cast<const void*>() == &i);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, &i}.cast<void*>(r));
|
||||
CHECK(uarg{r, &i}.cast<const void*>(r) == &i);
|
||||
}
|
||||
|
||||
SUBCASE("D* -> void*") {
|
||||
@@ -83,11 +85,11 @@ TEST_CASE("meta/meta_utilities/arg7/cast/to_void") {
|
||||
static_assert(std::is_invocable_v<void(void*), D*>);
|
||||
static_assert(std::is_invocable_v<void(const void*), D*>);
|
||||
|
||||
CHECK(uarg{&d}.can_cast_to<void*>());
|
||||
CHECK(uarg{&d}.can_cast_to<const void*>());
|
||||
CHECK(uarg{r, &d}.can_cast_to<void*>(r));
|
||||
CHECK(uarg{r, &d}.can_cast_to<const void*>(r));
|
||||
|
||||
CHECK(uarg{&d}.cast<void*>() == &d);
|
||||
CHECK(uarg{&d}.cast<const void*>() == &d);
|
||||
CHECK(uarg{r, &d}.cast<void*>(r) == &d);
|
||||
CHECK(uarg{r, &d}.cast<const void*>(r) == &d);
|
||||
}
|
||||
|
||||
SUBCASE("const D* -> void*") {
|
||||
@@ -96,11 +98,11 @@ TEST_CASE("meta/meta_utilities/arg7/cast/to_void") {
|
||||
static_assert(!std::is_invocable_v<void(void*), const D*>);
|
||||
static_assert(std::is_invocable_v<void(const void*), const D*>);
|
||||
|
||||
CHECK_FALSE(uarg{&d}.can_cast_to<void*>());
|
||||
CHECK(uarg{&d}.can_cast_to<const void*>());
|
||||
CHECK_FALSE(uarg{r, &d}.can_cast_to<void*>(r));
|
||||
CHECK(uarg{r, &d}.can_cast_to<const void*>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{&d}.cast<void*>());
|
||||
CHECK(uarg{&d}.cast<const void*>() == &d);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, &d}.cast<void*>(r));
|
||||
CHECK(uarg{r, &d}.cast<const void*>(r) == &d);
|
||||
}
|
||||
|
||||
SUBCASE("D[2] -> void*") {
|
||||
@@ -109,11 +111,11 @@ TEST_CASE("meta/meta_utilities/arg7/cast/to_void") {
|
||||
static_assert(std::is_invocable_v<void(void*), D (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const void*), D (&) [2]>);
|
||||
|
||||
CHECK(uarg{arr}.can_cast_to<void*>());
|
||||
CHECK(uarg{arr}.can_cast_to<const void*>());
|
||||
CHECK(uarg{r, arr}.can_cast_to<void*>(r));
|
||||
CHECK(uarg{r, arr}.can_cast_to<const void*>(r));
|
||||
|
||||
CHECK(uarg{arr}.cast<void*>() == &arr);
|
||||
CHECK(uarg{arr}.cast<const void*>() == &arr);
|
||||
CHECK(uarg{r, arr}.cast<void*>(r) == &arr);
|
||||
CHECK(uarg{r, arr}.cast<const void*>(r) == &arr);
|
||||
}
|
||||
|
||||
SUBCASE("const D[2] -> void*") {
|
||||
@@ -122,17 +124,19 @@ TEST_CASE("meta/meta_utilities/arg7/cast/to_void") {
|
||||
static_assert(!std::is_invocable_v<void(void*), const D (&) [2]>);
|
||||
static_assert(std::is_invocable_v<void(const void*), const D (&) [2]>);
|
||||
|
||||
CHECK_FALSE(uarg{arr}.can_cast_to<void*>());
|
||||
CHECK(uarg{arr}.can_cast_to<const void*>());
|
||||
CHECK_FALSE(uarg{r, arr}.can_cast_to<void*>(r));
|
||||
CHECK(uarg{r, arr}.can_cast_to<const void*>(r));
|
||||
|
||||
// CHECK_THROWS(std::ignore = uarg{arr}.cast<void*>());
|
||||
CHECK(uarg{arr}.cast<const void*>() == &arr);
|
||||
// CHECK_THROWS(std::ignore = uarg{r, arr}.cast<void*>(r));
|
||||
CHECK(uarg{r, arr}.cast<const void*>(r) == &arr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("meta/meta_utilities/arg7/cast/from_nullptr") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
SUBCASE("nullptr -> *") {
|
||||
static_assert(std::is_invocable_v<void(int*), std::nullptr_t>);
|
||||
@@ -152,46 +156,46 @@ TEST_CASE("meta/meta_utilities/arg7/cast/from_nullptr") {
|
||||
std::nullptr_t n1{nullptr};
|
||||
const std::nullptr_t n2{nullptr};
|
||||
|
||||
CHECK(uarg{n1}.can_cast_to<int*>());
|
||||
CHECK(uarg{std::move(n1)}.can_cast_to<int*>());
|
||||
CHECK(uarg{n2}.can_cast_to<int*>());
|
||||
CHECK(uarg{std::move(n2)}.can_cast_to<int*>());
|
||||
CHECK(uarg{r, n1}.can_cast_to<int*>(r));
|
||||
CHECK(uarg{r, std::move(n1)}.can_cast_to<int*>(r));
|
||||
CHECK(uarg{r, n2}.can_cast_to<int*>(r));
|
||||
CHECK(uarg{r, std::move(n2)}.can_cast_to<int*>(r));
|
||||
|
||||
CHECK(uarg{n1}.can_cast_to<const int*>());
|
||||
CHECK(uarg{std::move(n1)}.can_cast_to<const int*>());
|
||||
CHECK(uarg{n2}.can_cast_to<const int*>());
|
||||
CHECK(uarg{std::move(n2)}.can_cast_to<const int*>());
|
||||
CHECK(uarg{r, n1}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, std::move(n1)}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, n2}.can_cast_to<const int*>(r));
|
||||
CHECK(uarg{r, std::move(n2)}.can_cast_to<const int*>(r));
|
||||
|
||||
CHECK(uarg{n1}.can_cast_to<D*>());
|
||||
CHECK(uarg{std::move(n1)}.can_cast_to<D*>());
|
||||
CHECK(uarg{n2}.can_cast_to<D*>());
|
||||
CHECK(uarg{std::move(n2)}.can_cast_to<D*>());
|
||||
CHECK(uarg{r, n1}.can_cast_to<D*>(r));
|
||||
CHECK(uarg{r, std::move(n1)}.can_cast_to<D*>(r));
|
||||
CHECK(uarg{r, n2}.can_cast_to<D*>(r));
|
||||
CHECK(uarg{r, std::move(n2)}.can_cast_to<D*>(r));
|
||||
|
||||
CHECK(uarg{n1}.can_cast_to<const D*>());
|
||||
CHECK(uarg{std::move(n1)}.can_cast_to<const D*>());
|
||||
CHECK(uarg{n2}.can_cast_to<const D*>());
|
||||
CHECK(uarg{std::move(n2)}.can_cast_to<const D*>());
|
||||
CHECK(uarg{r, n1}.can_cast_to<const D*>(r));
|
||||
CHECK(uarg{r, std::move(n1)}.can_cast_to<const D*>(r));
|
||||
CHECK(uarg{r, n2}.can_cast_to<const D*>(r));
|
||||
CHECK(uarg{r, std::move(n2)}.can_cast_to<const D*>(r));
|
||||
|
||||
//
|
||||
|
||||
CHECK(uarg{n1}.cast<int*>() == nullptr);
|
||||
CHECK(uarg{std::move(n1)}.cast<int*>() == nullptr);
|
||||
CHECK(uarg{n2}.cast<int*>() == nullptr);
|
||||
CHECK(uarg{std::move(n2)}.cast<int*>() == nullptr);
|
||||
CHECK(uarg{r, n1}.cast<int*>(r) == nullptr);
|
||||
CHECK(uarg{r, std::move(n1)}.cast<int*>(r) == nullptr);
|
||||
CHECK(uarg{r, n2}.cast<int*>(r) == nullptr);
|
||||
CHECK(uarg{r, std::move(n2)}.cast<int*>(r) == nullptr);
|
||||
|
||||
CHECK(uarg{n1}.cast<const int*>() == nullptr);
|
||||
CHECK(uarg{std::move(n1)}.cast<const int*>() == nullptr);
|
||||
CHECK(uarg{n2}.cast<const int*>() == nullptr);
|
||||
CHECK(uarg{std::move(n2)}.cast<const int*>() == nullptr);
|
||||
CHECK(uarg{r, n1}.cast<const int*>(r) == nullptr);
|
||||
CHECK(uarg{r, std::move(n1)}.cast<const int*>(r) == nullptr);
|
||||
CHECK(uarg{r, n2}.cast<const int*>(r) == nullptr);
|
||||
CHECK(uarg{r, std::move(n2)}.cast<const int*>(r) == nullptr);
|
||||
|
||||
CHECK(uarg{n1}.cast<D*>() == nullptr);
|
||||
CHECK(uarg{std::move(n1)}.cast<D*>() == nullptr);
|
||||
CHECK(uarg{n2}.cast<D*>() == nullptr);
|
||||
CHECK(uarg{std::move(n2)}.cast<D*>() == nullptr);
|
||||
CHECK(uarg{r, n1}.cast<D*>(r) == nullptr);
|
||||
CHECK(uarg{r, std::move(n1)}.cast<D*>(r) == nullptr);
|
||||
CHECK(uarg{r, n2}.cast<D*>(r) == nullptr);
|
||||
CHECK(uarg{r, std::move(n2)}.cast<D*>(r) == nullptr);
|
||||
|
||||
CHECK(uarg{n1}.cast<const D*>() == nullptr);
|
||||
CHECK(uarg{std::move(n1)}.cast<const D*>() == nullptr);
|
||||
CHECK(uarg{n2}.cast<const D*>() == nullptr);
|
||||
CHECK(uarg{std::move(n2)}.cast<const D*>() == nullptr);
|
||||
CHECK(uarg{r, n1}.cast<const D*>(r) == nullptr);
|
||||
CHECK(uarg{r, std::move(n1)}.cast<const D*>(r) == nullptr);
|
||||
CHECK(uarg{r, n2}.cast<const D*>(r) == nullptr);
|
||||
CHECK(uarg{r, std::move(n2)}.cast<const D*>(r) == nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,16 +74,16 @@ namespace
|
||||
meta::function f_state{function_state::make<meta::function_policy::as_copy_t>("", function_ptr, {})};\
|
||||
\
|
||||
if ( std::is_invocable_v<decltype(function_ptr), decltype(FromValue)> ) {\
|
||||
CHECK(uarg{FromValue}.can_cast_to<ToType>());\
|
||||
CHECK(uarg_base{type_list<decltype(FromValue)>{}}.can_cast_to<ToType>());\
|
||||
std::ignore = uarg{FromValue}.cast<ToType>();\
|
||||
CHECK(uarg{r, FromValue}.can_cast_to<ToType>(r));\
|
||||
CHECK(uarg_base{r, type_list<decltype(FromValue)>{}}.can_cast_to<ToType>(r));\
|
||||
std::ignore = uarg{r, FromValue}.cast<ToType>(r);\
|
||||
\
|
||||
CHECK(f_state.is_invocable_with<decltype(FromValue)>());\
|
||||
CHECK(f_state.invoke(FromValue).get_as<int>() == 1);\
|
||||
} else {\
|
||||
CHECK_FALSE(uarg{FromValue}.can_cast_to<ToType>());\
|
||||
CHECK_FALSE(uarg_base{type_list<decltype(FromValue)>{}}.can_cast_to<ToType>());\
|
||||
/*CHECK_THROWS(std::ignore = uarg{FromValue}.cast<ToType>());*/\
|
||||
CHECK_FALSE(uarg{r, FromValue}.can_cast_to<ToType>(r));\
|
||||
CHECK_FALSE(uarg_base{r, type_list<decltype(FromValue)>{}}.can_cast_to<ToType>(r));\
|
||||
/*CHECK_THROWS(std::ignore = uarg{r, FromValue}.cast<ToType>(r));*/\
|
||||
\
|
||||
CHECK_FALSE(f_state.is_invocable_with<decltype(FromValue)>());\
|
||||
CHECK_FALSE(f_state.safe_invoke(FromValue));\
|
||||
@@ -118,6 +118,9 @@ TEST_CASE("meta/meta_utilities/arg") {
|
||||
|
||||
TEST_CASE("meta/meta_utilities/arg/refs") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
{
|
||||
// lvalue
|
||||
@@ -125,9 +128,9 @@ TEST_CASE("meta/meta_utilities/arg/refs") {
|
||||
auto LV2 = []() -> dclazz& { static dclazz v; return v; };
|
||||
auto LV3 = []() -> int& { static int v{1}; return v; };
|
||||
|
||||
meta::detail::uarg a{LV()};
|
||||
uarg a{r, LV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(LV(), f1, clazz)
|
||||
META_HPP_CHECK_INVOCABLE(LV(), f2, const clazz)
|
||||
@@ -157,9 +160,9 @@ TEST_CASE("meta/meta_utilities/arg/refs") {
|
||||
auto CLV2 = []() -> const dclazz& { static dclazz v; return v; };
|
||||
auto CLV3 = []() -> const int& { static int v{1}; return v; };
|
||||
|
||||
meta::detail::uarg a{CLV()};
|
||||
uarg a{r, CLV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(CLV(), f1, clazz)
|
||||
META_HPP_CHECK_INVOCABLE(CLV(), f2, const clazz)
|
||||
@@ -189,9 +192,9 @@ TEST_CASE("meta/meta_utilities/arg/refs") {
|
||||
auto XV2 = []() -> dclazz&& { static dclazz v; return std::move(v); };
|
||||
auto XV3 = []() -> int&& { static int v{1}; return std::move(v); };
|
||||
|
||||
meta::detail::uarg a{XV()};
|
||||
uarg a{r, XV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(XV(), f1, clazz)
|
||||
META_HPP_CHECK_INVOCABLE(XV(), f2, const clazz)
|
||||
@@ -221,9 +224,9 @@ TEST_CASE("meta/meta_utilities/arg/refs") {
|
||||
auto CXV2 = []() -> const dclazz&& { static dclazz v; return std::move(v); };
|
||||
auto CXV3 = []() -> const int&& { static int v{1}; return std::move(v); };
|
||||
|
||||
meta::detail::uarg a{CXV()};
|
||||
uarg a{r, CXV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(CXV(), f1, clazz)
|
||||
META_HPP_CHECK_INVOCABLE(CXV(), f2, const clazz)
|
||||
@@ -253,9 +256,9 @@ TEST_CASE("meta/meta_utilities/arg/refs") {
|
||||
auto PRV2 = []() -> dclazz { return dclazz{}; };
|
||||
auto PRV3 = []() -> int { return int{1}; };
|
||||
|
||||
meta::detail::uarg a{PRV()};
|
||||
uarg a{r, PRV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(PRV(), f1, clazz)
|
||||
META_HPP_CHECK_INVOCABLE(PRV(), f2, const clazz)
|
||||
@@ -284,9 +287,9 @@ TEST_CASE("meta/meta_utilities/arg/refs") {
|
||||
auto CPRV = []() -> const clazz { return clazz{}; };
|
||||
auto CPRV2 = []() -> const dclazz { return dclazz{}; };
|
||||
|
||||
meta::detail::uarg a{CPRV()};
|
||||
uarg a{r, CPRV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(CPRV(), f1, clazz)
|
||||
META_HPP_CHECK_INVOCABLE(CPRV(), f2, const clazz)
|
||||
@@ -306,6 +309,9 @@ TEST_CASE("meta/meta_utilities/arg/refs") {
|
||||
|
||||
TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
{
|
||||
// lvalue
|
||||
@@ -314,9 +320,9 @@ TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
auto LV2_PTR = []() -> dclazz*& { static dclazz v; static dclazz* p{&v}; return p; };
|
||||
auto LV3_PTR = []() -> int*& { static int v{1}; static int* p{&v}; return p; };
|
||||
|
||||
meta::detail::uarg a{LV_PTR()};
|
||||
uarg a{r, LV_PTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(LV_PTR(), f1, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE(LV_PTR(), f2, clazz* const)
|
||||
@@ -365,9 +371,9 @@ TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
auto LV2_CPTR = []() -> const dclazz*& { static dclazz v; static const dclazz* p{&v}; return p; };
|
||||
auto LV3_CPTR = []() -> const int*& { static int v{1}; static const int* p{&v}; return p; };
|
||||
|
||||
meta::detail::uarg a{LV_CPTR()};
|
||||
uarg a{r, LV_CPTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<const clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(LV_CPTR(), f1, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE(LV_CPTR(), f2, clazz* const)
|
||||
@@ -420,9 +426,9 @@ TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
auto CLV2_PTR = []() -> dclazz* const& { static dclazz v; static dclazz* p{&v}; return p; };
|
||||
auto CLV3_PTR = []() -> int* const& { static int v{1}; static int* p{&v}; return p; };
|
||||
|
||||
meta::detail::uarg a{CLV_PTR()};
|
||||
uarg a{r, CLV_PTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(CLV_PTR(), f1, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE(CLV_PTR(), f2, clazz* const)
|
||||
@@ -471,9 +477,9 @@ TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
auto CLV2_CPTR = []() -> const dclazz* const& { static dclazz v; static const dclazz* p{&v}; return p; };
|
||||
auto CLV3_CPTR = []() -> const int* const& { static int v{1}; static const int* p{&v}; return p; };
|
||||
|
||||
meta::detail::uarg a{CLV_CPTR()};
|
||||
uarg a{r, CLV_CPTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<const clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(CLV_CPTR(), f1, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE(CLV_CPTR(), f2, clazz* const)
|
||||
@@ -526,9 +532,9 @@ TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
auto XV2_PTR = []() -> dclazz*&& { static dclazz v; static dclazz* p{&v}; return std::move(p); };
|
||||
auto XV3_PTR = []() -> int*&& { static int v{1}; static int* p{&v}; return std::move(p); };
|
||||
|
||||
meta::detail::uarg a{XV_PTR()};
|
||||
uarg a{r, XV_PTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(XV_PTR(), f1, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE(XV_PTR(), f2, clazz* const)
|
||||
@@ -577,9 +583,9 @@ TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
auto XV2_CPTR = []() -> const dclazz*&& { static dclazz v; static const dclazz* p{&v}; return std::move(p); };
|
||||
auto XV3_CPTR = []() -> const int*&& { static int v{1}; static const int* p{&v}; return std::move(p); };
|
||||
|
||||
meta::detail::uarg a{XV_CPTR()};
|
||||
uarg a{r, XV_CPTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<const clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(XV_CPTR(), f1, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE(XV_CPTR(), f2, clazz* const)
|
||||
@@ -632,9 +638,9 @@ TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
auto CXV2_PTR = []() -> dclazz* const&& { static dclazz v; static dclazz* p{&v}; return std::move(p); };
|
||||
auto CXV3_PTR = []() -> int* const&& { static int v{1}; static int* p{&v}; return std::move(p); };
|
||||
|
||||
meta::detail::uarg a{CXV_PTR()};
|
||||
uarg a{r, CXV_PTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(CXV_PTR(), f1, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE(CXV_PTR(), f2, clazz* const)
|
||||
@@ -683,9 +689,9 @@ TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
auto CXV2_CPTR = []() -> const dclazz* const&& { static dclazz v; static const dclazz* p{&v}; return std::move(p); };
|
||||
auto CXV3_CPTR = []() -> const int* const&& { static int v{1}; static const int* p{&v}; return std::move(p); };
|
||||
|
||||
meta::detail::uarg a{CXV_CPTR()};
|
||||
uarg a{r, CXV_CPTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<const clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(CXV_CPTR(), f1, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE(CXV_CPTR(), f2, clazz* const)
|
||||
@@ -738,9 +744,9 @@ TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
auto PRV2_PTR = []() -> dclazz* { static dclazz v; static dclazz* p{&v}; return p; };
|
||||
auto PRV3_PTR = []() -> int* { static int v{1}; static int* p{&v}; return p; };
|
||||
|
||||
meta::detail::uarg a{PRV_PTR()};
|
||||
uarg a{r, PRV_PTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(PRV_PTR(), f1, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE(PRV_PTR(), f2, clazz* const)
|
||||
@@ -789,9 +795,9 @@ TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
auto PRV2_CPTR = []() -> const dclazz* { static dclazz v; static const dclazz* p{&v}; return p; };
|
||||
auto PRV3_CPTR = []() -> const int* { static int v{1}; static const int* p{&v}; return p; };
|
||||
|
||||
meta::detail::uarg a{PRV_CPTR()};
|
||||
uarg a{r, PRV_CPTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<const clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(PRV_CPTR(), f1, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE(PRV_CPTR(), f2, clazz* const)
|
||||
@@ -840,15 +846,18 @@ TEST_CASE("meta/meta_utilities/arg/ptrs") {
|
||||
|
||||
TEST_CASE("meta/meta_utilities/arg/values") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
{
|
||||
auto LV = []() -> meta::uvalue& { static meta::uvalue v{clazz{}}; return v; };
|
||||
auto LV2 = []() -> meta::uvalue& { static meta::uvalue v{dclazz{}}; return v; };
|
||||
auto LV3 = []() -> meta::uvalue& { static meta::uvalue v{int{1}}; return v; };
|
||||
|
||||
meta::detail::uarg a{LV()};
|
||||
uarg a{r, LV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(LV(), f1, clazz&, clazz)
|
||||
META_HPP_CHECK_INVOCABLE_2(LV(), f2, clazz&, const clazz)
|
||||
@@ -877,9 +886,9 @@ TEST_CASE("meta/meta_utilities/arg/values") {
|
||||
auto CLV2 = []() -> const meta::uvalue& { static meta::uvalue v{dclazz{}}; return v; };
|
||||
auto CLV3 = []() -> const meta::uvalue& { static meta::uvalue v{int{1}}; return v; };
|
||||
|
||||
meta::detail::uarg a{CLV()};
|
||||
uarg a{r, CLV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CLV(), f1, const clazz&, clazz)
|
||||
META_HPP_CHECK_INVOCABLE_2(CLV(), f2, const clazz&, const clazz)
|
||||
@@ -908,9 +917,9 @@ TEST_CASE("meta/meta_utilities/arg/values") {
|
||||
auto XV2 = []() -> meta::uvalue&& { static meta::uvalue v{dclazz{}}; return std::move(v); };
|
||||
auto XV3 = []() -> meta::uvalue&& { static meta::uvalue v{int{1}}; return std::move(v); };
|
||||
|
||||
meta::detail::uarg a{XV()};
|
||||
uarg a{r, XV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(XV(), f1, clazz&&, clazz)
|
||||
META_HPP_CHECK_INVOCABLE_2(XV(), f2, clazz&&, const clazz)
|
||||
@@ -939,9 +948,9 @@ TEST_CASE("meta/meta_utilities/arg/values") {
|
||||
auto CXV2 = []() -> const meta::uvalue&& { static meta::uvalue v{dclazz{}}; return std::move(v); };
|
||||
auto CXV3 = []() -> const meta::uvalue&& { static meta::uvalue v{int{1}}; return std::move(v); };
|
||||
|
||||
meta::detail::uarg a{CXV()};
|
||||
uarg a{r, CXV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CXV(), f1, const clazz&&, clazz)
|
||||
META_HPP_CHECK_INVOCABLE_2(CXV(), f2, const clazz&&, const clazz)
|
||||
@@ -970,9 +979,9 @@ TEST_CASE("meta/meta_utilities/arg/values") {
|
||||
auto PRV2 = []() -> meta::uvalue { return meta::uvalue{dclazz{}}; };
|
||||
auto PRV3 = []() -> meta::uvalue { return meta::uvalue{int{1}}; };
|
||||
|
||||
meta::detail::uarg a{PRV()};
|
||||
uarg a{r, PRV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(PRV(), f1, clazz, clazz)
|
||||
META_HPP_CHECK_INVOCABLE_2(PRV(), f2, clazz, const clazz)
|
||||
@@ -1001,9 +1010,9 @@ TEST_CASE("meta/meta_utilities/arg/values") {
|
||||
auto CPRV2 = []() -> const meta::uvalue { return meta::uvalue{dclazz{}}; };
|
||||
auto CPRV3 = []() -> const meta::uvalue { return meta::uvalue{int{1}}; };
|
||||
|
||||
meta::detail::uarg a{CPRV()};
|
||||
uarg a{r, CPRV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CPRV(), f1, const clazz, clazz)
|
||||
META_HPP_CHECK_INVOCABLE_2(CPRV(), f2, const clazz, const clazz)
|
||||
@@ -1030,14 +1039,17 @@ TEST_CASE("meta/meta_utilities/arg/values") {
|
||||
|
||||
TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
{
|
||||
auto LV_PTR = []() -> meta::uvalue& { static clazz v; static clazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
auto LV2_PTR = []() -> meta::uvalue& { static dclazz v; static dclazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
|
||||
meta::detail::uarg a{LV_PTR()};
|
||||
uarg a{r, LV_PTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(LV_PTR(), f1, clazz*&, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(LV_PTR(), f2, clazz*&, clazz* const)
|
||||
@@ -1072,9 +1084,9 @@ TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
auto LV_CPTR = []() -> meta::uvalue& { static clazz v; static const clazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
auto LV2_CPTR = []() -> meta::uvalue& { static dclazz v; static const dclazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
|
||||
meta::detail::uarg a{LV_CPTR()};
|
||||
uarg a{r, LV_CPTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<const clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(LV_CPTR(), f1, const clazz*&, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(LV_CPTR(), f2, const clazz*&, clazz* const)
|
||||
@@ -1109,9 +1121,9 @@ TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
auto CLV_PTR = []() -> const meta::uvalue& { static clazz v; static clazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
auto CLV2_PTR = []() -> const meta::uvalue& { static dclazz v; static dclazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
|
||||
meta::detail::uarg a{CLV_PTR()};
|
||||
uarg a{r, CLV_PTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CLV_PTR(), f1, clazz* const&, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(CLV_PTR(), f2, clazz* const&, clazz* const)
|
||||
@@ -1146,9 +1158,9 @@ TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
auto CLV_CPTR = []() -> const meta::uvalue& { static clazz v; static const clazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
auto CLV2_CPTR = []() -> const meta::uvalue& { static dclazz v; static const dclazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
|
||||
meta::detail::uarg a{CLV_CPTR()};
|
||||
uarg a{r, CLV_CPTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<const clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CLV_CPTR(), f1, const clazz* const&, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(CLV_CPTR(), f2, const clazz* const&, clazz* const)
|
||||
@@ -1183,9 +1195,9 @@ TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
auto XV_PTR = []() -> meta::uvalue&& { static clazz v; static clazz* p{&v}; static meta::uvalue vv{std::move(p)}; return std::move(vv); };
|
||||
auto XV2_PTR = []() -> meta::uvalue&& { static dclazz v; static dclazz* p{&v}; static meta::uvalue vv{std::move(p)}; return std::move(vv); };
|
||||
|
||||
meta::detail::uarg a{XV_PTR()};
|
||||
uarg a{r, XV_PTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(XV_PTR(), f1, clazz*&&, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(XV_PTR(), f2, clazz*&&, clazz* const)
|
||||
@@ -1220,9 +1232,9 @@ TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
auto XV_CPTR = []() -> meta::uvalue&& { static clazz v; static const clazz* p{&v}; static meta::uvalue vv{std::move(p)}; return std::move(vv); };
|
||||
auto XV2_CPTR = []() -> meta::uvalue&& { static dclazz v; static const dclazz* p{&v}; static meta::uvalue vv{std::move(p)}; return std::move(vv); };
|
||||
|
||||
meta::detail::uarg a{XV_CPTR()};
|
||||
uarg a{r, XV_CPTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<const clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(XV_CPTR(), f1, const clazz*&&, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(XV_CPTR(), f2, const clazz*&&, clazz* const)
|
||||
@@ -1257,9 +1269,9 @@ TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
auto CXV_PTR = []() -> const meta::uvalue&& { static clazz v; static clazz* p{&v}; static meta::uvalue vv{std::move(p)}; return std::move(vv); };
|
||||
auto CXV2_PTR = []() -> const meta::uvalue&& { static dclazz v; static dclazz* p{&v}; static meta::uvalue vv{std::move(p)}; return std::move(vv); };
|
||||
|
||||
meta::detail::uarg a{CXV_PTR()};
|
||||
uarg a{r, CXV_PTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CXV_PTR(), f1, clazz* const&&, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(CXV_PTR(), f2, clazz* const&&, clazz* const)
|
||||
@@ -1294,9 +1306,9 @@ TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
auto CXV_CPTR = []() -> const meta::uvalue&& { static clazz v; static const clazz* p{&v}; static meta::uvalue vv{std::move(p)}; return std::move(vv); };
|
||||
auto CXV2_CPTR = []() -> const meta::uvalue&& { static dclazz v; static const dclazz* p{&v}; static meta::uvalue vv{std::move(p)}; return std::move(vv); };
|
||||
|
||||
meta::detail::uarg a{CXV_CPTR()};
|
||||
uarg a{r, CXV_CPTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<const clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CXV_CPTR(), f1, const clazz* const&&, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(CXV_CPTR(), f2, const clazz* const&&, clazz* const)
|
||||
@@ -1331,9 +1343,9 @@ TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
auto PRV_PTR = []() -> meta::uvalue { static clazz v; static clazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
auto PRV2_PTR = []() -> meta::uvalue { static dclazz v; static dclazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
|
||||
meta::detail::uarg a{PRV_PTR()};
|
||||
uarg a{r, PRV_PTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(PRV_PTR(), f1, clazz*, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(PRV_PTR(), f2, clazz*, clazz* const)
|
||||
@@ -1368,9 +1380,9 @@ TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
auto PRV_CPTR = []() -> meta::uvalue { static clazz v; static const clazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
auto PRV2_CPTR = []() -> meta::uvalue { static dclazz v; static const dclazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
|
||||
meta::detail::uarg a{PRV_CPTR()};
|
||||
uarg a{r, PRV_CPTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<const clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(PRV_CPTR(), f1, const clazz*, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(PRV_CPTR(), f2, const clazz*, clazz* const)
|
||||
@@ -1405,9 +1417,9 @@ TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
auto CPRV_PTR = []() -> const meta::uvalue { static clazz v; static clazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
auto CPRV2_PTR = []() -> const meta::uvalue { static dclazz v; static dclazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
|
||||
meta::detail::uarg a{CPRV_PTR()};
|
||||
uarg a{r, CPRV_PTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CPRV_PTR(), f1, clazz* const, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(CPRV_PTR(), f2, clazz* const, clazz* const)
|
||||
@@ -1442,9 +1454,9 @@ TEST_CASE("meta/meta_utilities/arg/ptr_values") {
|
||||
auto CPRV_CPTR = []() -> const meta::uvalue { static clazz v; static const clazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
auto CPRV2_CPTR = []() -> const meta::uvalue { static dclazz v; static const dclazz* p{&v}; static meta::uvalue vv{p}; return vv; };
|
||||
|
||||
meta::detail::uarg a{CPRV_CPTR()};
|
||||
uarg a{r, CPRV_CPTR()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<const clazz*>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CPRV_CPTR(), f1, const clazz* const, clazz*)
|
||||
META_HPP_CHECK_INVOCABLE_2(CPRV_CPTR(), f2, const clazz* const, clazz* const)
|
||||
|
||||
@@ -34,16 +34,16 @@ namespace
|
||||
meta::method m_state{method_state::make<meta::method_policy::as_copy_t>("", method_ptr, {})};\
|
||||
\
|
||||
if ( std::is_invocable_v<decltype(method_ptr), decltype(Inst)> ) {\
|
||||
CHECK(uinst{Inst}.can_cast_to<clazz Qualifiers>());\
|
||||
CHECK(uinst_base{type_list<decltype(Inst)>{}}.can_cast_to<clazz Qualifiers>());\
|
||||
std::ignore = uinst{Inst}.cast<clazz Qualifiers>();\
|
||||
CHECK(uinst{r, Inst}.can_cast_to<clazz Qualifiers>(r));\
|
||||
CHECK(uinst_base{r, type_list<decltype(Inst)>{}}.can_cast_to<clazz Qualifiers>(r));\
|
||||
std::ignore = uinst{r, Inst}.cast<clazz Qualifiers>(r);\
|
||||
\
|
||||
CHECK(m_state.is_invocable_with<decltype(Inst)>());\
|
||||
CHECK(m_state.invoke(Inst).get_as<int>() == 1);\
|
||||
} else {\
|
||||
CHECK_FALSE(uinst{Inst}.can_cast_to<clazz Qualifiers>());\
|
||||
CHECK_FALSE(uinst_base{type_list<decltype(Inst)>{}}.can_cast_to<clazz Qualifiers>());\
|
||||
/*CHECK_THROWS(std::ignore = uinst{Inst}.cast<clazz Qualifiers>());*/\
|
||||
CHECK_FALSE(uinst{r, Inst}.can_cast_to<clazz Qualifiers>(r));\
|
||||
CHECK_FALSE(uinst_base{r, type_list<decltype(Inst)>{}}.can_cast_to<clazz Qualifiers>(r));\
|
||||
/*CHECK_THROWS(std::ignore = uinst{r, Inst}.cast<clazz Qualifiers>(r));*/\
|
||||
\
|
||||
CHECK_FALSE(m_state.is_invocable_with<decltype(Inst)>());\
|
||||
CHECK_FALSE(m_state.safe_invoke(Inst));\
|
||||
@@ -78,6 +78,10 @@ TEST_CASE("meta/meta_utilities/inst2") {
|
||||
|
||||
TEST_CASE("meta/meta_utilities/inst2/refs") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::uinst;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
{
|
||||
// lvalue
|
||||
@@ -85,9 +89,9 @@ TEST_CASE("meta/meta_utilities/inst2/refs") {
|
||||
auto LV2 = []() -> dclazz& { static dclazz v; return v; };
|
||||
|
||||
{
|
||||
meta::detail::uinst i{LV()};
|
||||
uinst i{r, LV()};
|
||||
CHECK(i.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(i.get_ref_type() == meta::detail::uinst::ref_types::lvalue);
|
||||
CHECK(i.get_ref_type() == uinst::ref_types::lvalue);
|
||||
}
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(LV(), m1, )
|
||||
@@ -111,9 +115,9 @@ TEST_CASE("meta/meta_utilities/inst2/refs") {
|
||||
auto CLV2 = []() -> const dclazz& { static dclazz v; return v; };
|
||||
|
||||
{
|
||||
meta::detail::uinst i{CLV()};
|
||||
uinst i{r, CLV()};
|
||||
CHECK(i.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(i.get_ref_type() == meta::detail::uinst::ref_types::const_lvalue);
|
||||
CHECK(i.get_ref_type() == uinst::ref_types::const_lvalue);
|
||||
}
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(CLV(), m1, )
|
||||
@@ -137,9 +141,9 @@ TEST_CASE("meta/meta_utilities/inst2/refs") {
|
||||
auto XV2 = []() -> dclazz&& { static dclazz v; return std::move(v); };
|
||||
|
||||
{
|
||||
meta::detail::uinst i{XV()};
|
||||
uinst i{r, XV()};
|
||||
CHECK(i.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(i.get_ref_type() == meta::detail::uinst::ref_types::rvalue);
|
||||
CHECK(i.get_ref_type() == uinst::ref_types::rvalue);
|
||||
}
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(XV(), m1, )
|
||||
@@ -163,9 +167,9 @@ TEST_CASE("meta/meta_utilities/inst2/refs") {
|
||||
auto CXV2 = []() -> const dclazz&& { static dclazz v; return std::move(v); };
|
||||
|
||||
{
|
||||
meta::detail::uinst i{CXV()};
|
||||
uinst i{r, CXV()};
|
||||
CHECK(i.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(i.get_ref_type() == meta::detail::uinst::ref_types::const_rvalue);
|
||||
CHECK(i.get_ref_type() == uinst::ref_types::const_rvalue);
|
||||
}
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(CXV(), m1, )
|
||||
@@ -189,9 +193,9 @@ TEST_CASE("meta/meta_utilities/inst2/refs") {
|
||||
auto PRV2 = []() -> dclazz { return dclazz{}; };
|
||||
|
||||
{
|
||||
meta::detail::uinst i{PRV()};
|
||||
uinst i{r, PRV()};
|
||||
CHECK(i.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(i.get_ref_type() == meta::detail::uinst::ref_types::rvalue);
|
||||
CHECK(i.get_ref_type() == uinst::ref_types::rvalue);
|
||||
}
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(PRV(), m1, )
|
||||
@@ -215,9 +219,9 @@ TEST_CASE("meta/meta_utilities/inst2/refs") {
|
||||
auto CPRV2 = []() -> const dclazz { return dclazz{}; };
|
||||
|
||||
{
|
||||
meta::detail::uinst i{CPRV()};
|
||||
uinst i{r, CPRV()};
|
||||
CHECK(i.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(i.get_ref_type() == meta::detail::uinst::ref_types::const_rvalue);
|
||||
CHECK(i.get_ref_type() == uinst::ref_types::const_rvalue);
|
||||
}
|
||||
|
||||
META_HPP_CHECK_INVOCABLE(CPRV(), m1, )
|
||||
@@ -238,15 +242,19 @@ TEST_CASE("meta/meta_utilities/inst2/refs") {
|
||||
|
||||
TEST_CASE("meta/meta_utilities/inst2/values") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::uarg;
|
||||
using meta::detail::uinst;
|
||||
using meta::detail::type_registry;
|
||||
type_registry& r{type_registry::instance()};
|
||||
|
||||
{
|
||||
// lvalue
|
||||
auto LV = []() -> meta::uvalue& { static meta::uvalue v{clazz{}}; return v; };
|
||||
auto LV2 = []() -> meta::uvalue& { static meta::uvalue v{dclazz{}}; return v; };
|
||||
|
||||
meta::detail::uarg a{LV()};
|
||||
uarg a{r, LV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(LV(), m1, clazz&, )
|
||||
META_HPP_CHECK_INVOCABLE_2(LV(), m2, clazz&, &)
|
||||
@@ -268,9 +276,9 @@ TEST_CASE("meta/meta_utilities/inst2/values") {
|
||||
auto CLV = []() -> const meta::uvalue& { static meta::uvalue v{clazz{}}; return v; };
|
||||
auto CLV2 = []() -> const meta::uvalue& { static meta::uvalue v{dclazz{}}; return v; };
|
||||
|
||||
meta::detail::uarg a{CLV()};
|
||||
uarg a{r, CLV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_lvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_lvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CLV(), m1, const clazz&, )
|
||||
META_HPP_CHECK_INVOCABLE_2(CLV(), m2, const clazz&, &)
|
||||
@@ -292,9 +300,9 @@ TEST_CASE("meta/meta_utilities/inst2/values") {
|
||||
auto XV = []() -> meta::uvalue&& { static meta::uvalue v{clazz{}}; return std::move(v); };
|
||||
auto XV2 = []() -> meta::uvalue&& { static meta::uvalue v{dclazz{}}; return std::move(v); };
|
||||
|
||||
meta::detail::uarg a{XV()};
|
||||
uarg a{r, XV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(XV(), m1, clazz&&, )
|
||||
META_HPP_CHECK_INVOCABLE_2(XV(), m2, clazz&&, &)
|
||||
@@ -316,9 +324,9 @@ TEST_CASE("meta/meta_utilities/inst2/values") {
|
||||
auto CXV = []() -> const meta::uvalue&& { static meta::uvalue v{clazz{}}; return std::move(v); };
|
||||
auto CXV2 = []() -> const meta::uvalue&& { static meta::uvalue v{dclazz{}}; return std::move(v); };
|
||||
|
||||
meta::detail::uarg a{CXV()};
|
||||
uarg a{r, CXV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CXV(), m1, const clazz&&, )
|
||||
META_HPP_CHECK_INVOCABLE_2(CXV(), m2, const clazz&&, &)
|
||||
@@ -340,9 +348,9 @@ TEST_CASE("meta/meta_utilities/inst2/values") {
|
||||
auto PRV = []() -> meta::uvalue { return meta::uvalue{clazz{}}; };
|
||||
auto PRV2 = []() -> meta::uvalue { return meta::uvalue{dclazz{}}; };
|
||||
|
||||
meta::detail::uarg a{PRV()};
|
||||
uarg a{r, PRV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(PRV(), m1, clazz, )
|
||||
META_HPP_CHECK_INVOCABLE_2(PRV(), m2, clazz, &)
|
||||
@@ -364,9 +372,9 @@ TEST_CASE("meta/meta_utilities/inst2/values") {
|
||||
auto CPRV = []() -> const meta::uvalue { return meta::uvalue{clazz{}}; };
|
||||
auto CPRV2 = []() -> const meta::uvalue { return meta::uvalue{dclazz{}}; };
|
||||
|
||||
meta::detail::uarg a{CPRV()};
|
||||
uarg a{r, CPRV()};
|
||||
CHECK(a.get_raw_type() == meta::resolve_type<clazz>());
|
||||
CHECK(a.get_ref_type() == meta::detail::uarg::ref_types::const_rvalue);
|
||||
CHECK(a.get_ref_type() == uarg::ref_types::const_rvalue);
|
||||
|
||||
META_HPP_CHECK_INVOCABLE_2(CPRV(), m1, const clazz, )
|
||||
META_HPP_CHECK_INVOCABLE_2(CPRV(), m2, const clazz, &)
|
||||
|
||||
Reference in New Issue
Block a user