[xsd-users] Template for member created by Code Synthesis

Boris Kolpackov boris at codesynthesis.com
Thu Feb 26 04:45:25 EST 2015


Hi Hillel,

Markowitz, Hillel [USA] <Markowitz_Hillel at bah.com> writes:

> I would like to set up templates to handle certain members that
> will be added in the future. I would like to use the templates
> so that I do not get a compilation file before the updated include
> files and libraries are installed.
> 
> 
> for example baseclass.myMemberA().push_back(basedata);

Ok, if I understood the above correctly, you are looking for a way
to test at C++-compile-time whether a class has a certain member.

If you are using C++11, this can be easily done with the expression
SFINAE. E.g., something along these lines:


template <typename T>
auto MemberA_push_back (const T* baseclass, const BaseData* basedata)
  -> decltype (baseclass->myMemberA().push_back (*basedata))
{
  baseclass->myMemberA().push_back (*basedata);
}

template <typename T>
void MemberA_push_back (...) {}

MemberA_push_back (&baseclass, &basedata)

You could also probably use enable_if instead of function return types.

Boris



More information about the xsd-users mailing list