gives the pointed to type of a pointer or pointertomember. That is, for P=T* it gives T, for P=T C::* it gives T. template gives the staticness of a pointer type given by std::class_member_pointer. If P=T* the member is static, if P=T C::* the member is nonstatic: template
2. Member Predicate We are now ready to define a predicate on which we are going to filter the members of the class. We are interested in public, nonstatic, functions. We simply define the predicate as the
conjuction of these three properties. is_pnsmf
3. Name Index Now we want to create an index of the names of the members that satisfy the predicate. First we need to calculate the storage requirements. We define a pnsmf_index_dim_t class to hold the number of strings and the number of total chars we need in the index: struct pnsmf_index_dims_t { size_t nstrings = 0; size_t nchars = 0; }; We then make a pass over the members to calculate these requirements. We use std::make_index_sequence and calculate the dimensions: template
} We then assign the dimensions to a static constexpr pnsmf_index_dims
if (s) { ret.stroff[current_stroff++] = current_chardata; for (const char* p = s; true; p++) { ret.chardata[current_chardata++] = *p; if (!*p) break; } } bool ok = true; do { ok = true; for (size_t i = 0; i+1 < dims.nstrings; i++) if (strlitcmp(ret.chardata + ret.stroff[i],ret.chardata + ret.stroff[i+1]) >= 0) { size_t t = ret.stroff[i]; ret.stroff[i] = ret.stroff[i+1]; ret.stroff[i+1] = t; ok = false; } } while (!ok); return ret; }; Then we create a static constexpr variable template pnsmf_index
4. The Function Itself Now that we have built the index, we can define the has_member_function function that performs a binary search of it:
template
Conclusion We should note that this use case is not a primary one for N4027 or for reflection in general. Also, we want to make clear that this is just a demo, for production purposes we anticipate production quality nonstandard reflection libraries will be built atop N4027 that have more sophistication than the quick direct demo indexing we have shown here. Our purpose for this demo is to prove that all the necessary information is exposed by our minimal compilesupported traits, and that it is possible to use it efficiently from pure library code. The code in this paper has been tested, and the code under Goal works as shown verbatim.