因此,我敲响了我的大脑,试图为一些事情铺路。 我认为,我在这里要看是否有任何想法。 考虑如下:
template <typename S, typename T, T S::* pMember>
bool SortByMember(const S& L, const S& R)
{
return L.*pMember < R.*pMember;
}
...
struct SomeStruct
{
int SomeMember;
};
void SomeFunction(void)
{
GetSortByMember<&SomeStruct::SomeMember>();
}
I would like the function, GetSortByMember, to return a function pointer to the corresponding instantiation of SortByMember. However, I can t think of a way to declare/define GetSortByMember in a way that doesn t require the user to also pass the class type and the member type. This:
GetSortByMember<SomeStruct, int, &SomeStruct::SomeMember>();
is overly verbose and requires me to state the member type. I m sure there s probably a solution in the boost libraries, but I d rather not introduce that dependency to the project I m working on.
我非常怀疑,存在一种解决办法,可产生代谢法中所用的精确合成物一,但也许可以用模板类别或宏观做些什么?
SortBy Members的签名按使用职能点的类别计算,因此可能不会改变。