UDRefl icon indicating copy to clipboard operation
UDRefl copied to clipboard

字段的类型为特定类型时,AddField函数无法通过编译

Open Steelwall2014 opened this issue 2 years ago • 1 comments

当字段类型为模板类,且这个模板类的模板参数中包括非类型模板参数,且这个参数为枚举类型时,AddField函数无法通过编译 最小示例:

#include <UDRefl/UDRefl.hpp>
using namespace Ubpa;
using namespace Ubpa::UDRefl;
enum Enum
{
	E1,
};
template<Enum e>
struct TStruct
{

};

struct MyStruct
{
	TStruct<E1> field;
};

int main()
{
	Mngr.RegisterType<MyStruct>();
	Mngr.AddField<&MyStruct::field>("field");	// 编译失败
	return 0;
}

编译器为msvc,报错信息:

D:\UDRefl\build\_deps\utemplate-src\include\UTemplate\details/Name.inl(127,5): error C2672: “concat_seq”: 未找到匹配的重载函数
1>D:\UDRefl\build\_deps\utemplate-src\include\UTemplate\details\../TStr.hpp(194,17): message : 可能是“auto Ubpa::concat_seq(Strs...) noexcept”
1>D:\UDRefl\build\_deps\utemplate-src\include\UTemplate\details/Name.inl(127,5): message : 未能使函数模板“auto Ubpa::concat_seq(Strs...) noexcept”专用化
1>D:\UDRefl\build\_deps\utemplate-src\include\UTemplate\details/Name.inl(127,5): message : 用下列模板参数:
1>D:\UDRefl\build\_deps\utemplate-src\include\UTemplate\details/Name.inl(127,5): message : “Strs={Ubpa::TStr<Ubpa::fixed_cstring<char,1>{char123,0}>, void, Ubpa::TStr<Ubpa::fixed_cstring<char,1>{char125,0}>}”
1>D:\UDRefl\build\_deps\utemplate-src\include\UTemplate\details/Name.inl(125,1): message : 在编译 类 模板 成员函数“auto Ubpa::details::template_args_name_impl<U>::get(void) noexcept”时
1>D:\UDRefl\build\_deps\utemplate-src\include\UTemplate\details/Name.inl(132): message : 查看对正在编译的 类 模板 实例化“Ubpa::details::template_args_name_impl<U>”的引用
1>D:\UDRefl\build\_deps\utemplate-src\include\UTemplate\details/Name.inl(191): message : 查看对正在编译的函数 模板 实例化“auto Ubpa::details::template_args_name<U>(void) noexcept”的引用
1>D:\UDRefl\build\_deps\utemplate-src\include\UTemplate/Type.hpp(205): message : 查看对正在编译的函数 模板 实例化“auto Ubpa::type_name<Value>(void) noexcept”的引用
1>D:\UDRefl\include\UDRefl\details/ReflMngr.inl(1027,6): message : 查看指向正在编译的变量模板“const Ubpa::Type Type_of<TStruct<0> >”的引用
1>D:\UDRefl\include\UDRefl\details/ReflMngr.inl(1250): message : 查看对正在编译的函数 模板 实例化“Ubpa::UDRefl::FieldPtr Ubpa::UDRefl::ReflMngr::GenerateFieldPtr<pointer-to-member(0x0),true>(void)”的引用
1>D:\UDRefl\src\test\02_const_static\main.cpp(141,33): message : 查看对正在编译的函数 模板 实例化“bool Ubpa::UDRefl::ReflMngr::AddField<pointer-to-member(0x0),true>(Ubpa::Name,Ubpa::UDRefl::AttrSet)”的引用

Steelwall2014 avatar May 19 '23 10:05 Steelwall2014

问题找到了,在UTemplate这个库中,Ubpa::detail::constexpr_value_name这个函数不能接收enum参数,否则就会编译报错,我在那里提了pr,求merge

Steelwall2014 avatar May 19 '23 12:05 Steelwall2014