Re: How to determine if class has call operator defined?
On 21 Feb., 23:03, Mathias Gaunard <loufo...@gmail.com> wrote:
On 21 f?v, 05:40, SG <s.gesem...@gmail.com> wrote:
You can't do that directly (for now / until C++0x comes out).
Yes you can.
I guess it depends on your definition of "directly". The OP asked for
concept-based specialization:
template<typename T>
class MyClass { /* default impl */ };
tempalte<typename T>
requires SomeConcept<T> // <-- C++0x feature
class MyClass<T> { /* some specialization */ };
I don't see how this can be done directly. He has to work out some
alternative possibly involving some meta function that selects some
base type for inheritence like:
template<typename T>
struct my_meta_function {
typedef /* INSERT MAGIC HERE */ base_type;
};
template<typename T>
class MyClass : public my_meta_function<T>::base_type {
/* ... */
};
A solution has been posted in the other response to the original
message.
This solution is not complete w.r.t. the OP's problem because it's
only about finding out whether some operator() function is defined or
not --- as far as I can tell.
C++0x concepts are mostly just syntactic sugar. Everything except
constructors and assignment operators can already be checked for in C+
+03.
Calling concepts "syntactic sugar" is an understatement in my opinion.
Cheers!
SG
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]