Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Steelwall2014 opened this issue May 19, 2023 · 1 comment

Comments

@Steelwall2014
Copy link

当字段类型为模板类,且这个模板类的模板参数中包括非类型模板参数,且这个参数为枚举类型时,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
Copy link
Author

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

StarBeat added a commit to StarBeat/UTemplate that referenced this issue Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant