Sign in to follow this  
  • entries
    46
  • comments
    67
  • views
    45288

MetaZen

Sign in to follow this  
Extrarius

220 views

C++ templates are fun. I hadn't gotten "warning C4503: decorated name length exceeded, name was truncated" in MSVS since I stopped using 6 years ago, but just now I had a project gain 85 such warnings after adding some classes like the following:
template 	typename TMemberType,
const TMemberType TClassType::*const TMemberPtr,
typename TPredicate = std::less >
struct TMemberCompare
{
private:
const TPredicate m_Predicate;
public:
TMemberCompare(){}
TMemberCompare(const TPredicate& p_Predicate)
:m_Predicate(p_Predicate)
{
}
bool operator()(const TClassType &p_Left, const TClassType &p_Right) const
{
return m_Predicate(p_Left.*TMemberPtr, p_Right.*TMemberPtr);
}
};
Is there a better way to make such comparison functors? I looked around in MSDN and Boost for such wrapper classes, but I couldn't find them so I created the above, another that derefs it's arguments and compares the result (for iterators), and a third that does a lexicographical_compare on two provided containers.
Of course, in some cases, they are chained, which causes the problem:
typedef TIteratorCompare TSymbolRefCompare;
typedef TContainerCompare TSymbolRefListCompare;
typedef TMemberCompare TExpressionCompare;
typedef TIteratorCompare TExpressionRefCompare;
typedef TContainerCompare TExpressionRefTableCompare;
//TExpressionRefTableCompare is used in a custom comparison functor for TAssertionCompare to make TAssertionTable

Thoughts/Comments/Suggestions?
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now