
AMDG Lorenzo Caminiti wrote:
It turned out that I only needed to check if a struct is declared within one of the base classes or not. This seems simpler that my original goal for has_function and I was able to adapt Ingo's code to get the job done -- see below. However, I am getting the following compiler error:
$ g++ -Wall -Werror test/noinherit/05.cpp test/noinherit/05.cpp: In instantiation of ‘const bool z::has_contract_f_<x>::value’: test/noinherit/05.cpp:34: instantiated from here test/noinherit/05.cpp:31: error: the default argument for parameter 1 of ‘static char z::has_contract_f_<T>::check(C*, typename C::contract_f_<0>*) [with C = x, T = x]’ has not yet been parsed
Do you know how I can get around this error? <snip> template<typename T> struct has_contract_f_ { private: typedef char true_t; struct false_t { true_t dummy[2]; }; static T* make();
static false_t check(...); template<typename C> static true_t check(C*, typename C::template contract_f_<0>* = 0); public: static const bool value = sizeof(check(make())) == sizeof(true_t); // line 31 };
<snip>
Does it work if you pass 0 explicitly instead of using a default argument. In Christ, Steven Watanabe