This commit is contained in:
BlackMATov
2024-09-21 22:10:54 +07:00
parent a2f428bbb8
commit f2db9c2a44
2 changed files with 30 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
/*******************************************************************************
* This file is part of the "https://github.com/blackmatov/meta.hpp"
* For conditions of distribution and use, see copyright notice in LICENSE.md
* Copyright (C) 2021-2024, by Matvey Cherevko (blackmatov@gmail.com)
******************************************************************************/
#include <meta.hpp/meta_all.hpp>
#include <doctest/doctest.h>
namespace
{
struct clazz {};
}
TEST_CASE("meta/meta_issues/104") {
namespace meta = meta_hpp;
using namespace std::string_literals;
meta::class_<clazz>()
.destructor_(meta::metadata_()("hello", "world"s));
CHECK(meta::resolve_type<clazz>().get_destructor().get_metadata().contains("hello"));
meta::class_<clazz>();
CHECK(meta::resolve_type<clazz>().get_destructor().get_metadata().contains("hello"));
}

View File

@@ -16,7 +16,9 @@ namespace meta_hpp
class_bind<Class>::class_bind(metadata_map metadata)
: type_bind_base{resolve_type<Class>(), std::move(metadata)} {
if constexpr ( std::is_destructible_v<Class> ) {
destructor_();
if ( get_data().destructors.empty() ) {
destructor_();
}
}
}