When I write a template class that I could change based on certain template special cases, then there are sometimes situations where even despite good encapsulation I find myself at debate between actually implementing a full template class specialization or just adding one or two attributes that in half of the cases would be unutilized.
Now, with a meta-programming property check I hope to find a good in-betweener.
The idea is (something) like:
template<Property ...myProperties>
struct PropertyList{
template<PropertyArgs ...args>
static constexpr bool is_satisfied = /*...*/;
};
And the idea is that this returns true if each property in arg is satisfied by at least one property of myProperties.
So for example if
myProperties={ Color is red , Color is green , Material is iron }
and
args={ Color is red , Material is iron }
then is_satisfied = true.
I have implemented this now myself ( I use Property<typename T, T t>{ is_satisfied = (S!=T) or (s==t); }; where T is typically an enum ) but I would be surprised if the standard just hasn't something for exactly this case.
Let me know what you use :)
PS: I use a lot of requirements (concepts) but I cannot make them suitable for those cases I have in mind with the properties such as, e.g., default assignments of attributes or constexpr branches / template arguments. (I see how this is the other way round to concepts: those determine branches on the function call receiver, whereas my properties could be used on the issuer side.)