[boost-users] [general question] deciding to use member function or not.

Hi is their a simple way *at compile time *to determine if a member function exist for a particular instance, if yes than use that function otherwise do not use it. example std::list<int> li; // check if unique is a member function of li, if yes use unique. li.unique(); // else use stl unique. std::unique(li.begin(), li.end());

I believe you can't do it in a generic way for all the classes. But if
you design your classes with support for concept_check ( see boost
concept check library for more info ) you can get pretty close. If C++
gets reflection support in future(hey it doesn't cost anything to
dream!) this can be even done at runtime.
Thanks,
Edwin
On 10/31/07, chun ping wang
Hi is their a simple way *at compile time *to determine if a member function exist for a particular instance, if yes than use that function otherwise do not use it.
example std::list<int> li; // check if unique is a member function of li, if yes use unique. li.unique(); // else use stl unique. std::unique(li.begin(), li.end());
participants (2)
-
chun ping wang
-
Edwin Savarimuthu