)
        .constructor(&ctor_test::create_object)
        .constructor(&global_create_object);
}

////////////////////////////////////////////////////////////////////////////////////////

TEST_CASE("constructor - retrieve", "[constructor]")
{
    type t = type::get<ctor_test>();
    REQUIRE(t.is_valid() == true);

    SECTION("retrieve default ctor")
    {
        constructor ctor = t.get_constructor();
        CHECK(ctor.is_valid() == true);
        CHECK(static_cast<bool>(ctor) == true);
    }

    SECTION("retrieve copy-ctor")
    {
        constructor ctor = t.get_constructor({type::get<ctor_test>()});
        CHECK(ctor.is_valid() == true);
        CHECK(static_cast<bool>(ctor) == true);
    }

    SECTION("retrieve custom ctor")
    {
        constructor ctor = t.get_constructor({type::get<int>(), type::get<double>()});
        CHECK(ctor.is_valid() == true);
        CHECK(static_cast<bool>(ctor) == true);
Пример #2
0
        .constructor(select_overload<ctor_func_invoke_arg_test(int, int, int, int, int, int, int)>(&ctor_func_invoke_arg_test::create))
        ;
#endif
}

////////////////////////////////////////////////////////////////////////////////////////

TEST_CASE("constructor - invoke general", "[constructor]")
{
    type t = type::get<ctor_invoke_test>();
    REQUIRE(t.is_valid() == true);

    SECTION("invoke default ctor")
    {
        constructor ctor = t.get_constructor();
        REQUIRE(ctor.is_valid() == true);

        variant var = ctor.invoke();
        CHECK(var.is_valid() == true);
        CHECK(var.get_type() == type::get<ctor_invoke_test*>());
        ctor_invoke_test* obj = var.get_value<ctor_invoke_test*>();
        CHECK(obj->default_ctor_invoked == true);
        CHECK(t.get_destructor().invoke(var) == true);
    }

    SECTION("invoke copy-ctor")
    {
        constructor ctor = t.get_constructor({type::get<ctor_invoke_test>()});
        REQUIRE(ctor.is_valid() == true);

        variant var = ctor.invoke(12);