0

Possible Duplicate:
How to detect whether there is a specific member variable in class?

I have a templated function that takes a struct as a parameter. If the struct contains the field "id" the function may continue, something like:

template<typename PointT>
void doSomething(PointT point) {
  if (containsField(point, "id")) {
    //do stuff
  }
}

I'm aware of specialization, unfortunatly PointT can be any type that has field id I believe I saw something similar in boost a while ao but can't find it anymore

any ideas??

Community
  • 1
  • 1
Moataz Elmasry
  • 2,509
  • 4
  • 27
  • 37
  • If `PointT` can be any type, that function should be a function template, right? – Andy Prowl Jan 25 '13 at 13:42
  • 1
    You probably need [SFINAE](http://en.wikipedia.org/wiki/Substitution_failure_is_not_an_error). – juanchopanza Jan 25 '13 at 13:43
  • for C++11 there is a simpler solution than the one in the linked question that I would like to provide, but I cannot do that if the question is closed – Andy Prowl Jan 25 '13 at 14:14
  • I don't have enough rights to reopen it, but maybe you can answer it in the linked question and let me know – Moataz Elmasry Jan 25 '13 at 14:19
  • @MoatazElmasry: done that: http://stackoverflow.com/questions/1005476/how-to-detect-whether-there-is-a-specific-member-variable-in-class/14523787#14523787 – Andy Prowl Jan 25 '13 at 14:33

0 Answers0