I tested the following code with GCC 4.9.0 and it is expected to be 3.5.15. The program outputs the 'true' in the expected form. However, if I remove the comment in front of the enum then it changes to 'wrong' what's happening here? How can I ensure that has_mem boolean is set to true My final goal is to have a member function in straight A, which is enabled by enabling if only then Class T has a fixed member function .
#include & lt; Iostream & gt; #include & lt; Boost / tti / has_member_function.hpp & gt; BOOST_TTI_HAS_MEMBER_FUNCTION (func) template & lt; Class T & gt; Structure A {// enum: bool {has_mem = has_member_function_func & lt; T, Zero, Promotion :: Emple :: Vector & lt; Const T & amp; & Gt; & Gt;: value}; A () {std :: cout & lt; & Lt; Std :: boolalpha & lt; & Lt; Has_member_function_func & lt; T, Zero, Promotion :: Emple :: Vector & lt; Constant & amp; & Gt; & Gt;: value & lt; & Lt; "\ N"; }}; Structure B: Public A & LT; B & gt; {Zero Funk (const B & amp;) {}}; Int main () {B b; }
I came to know that the following problem resolves my problem.
#include & lt; Iostream & gt; Struct empty_ {}; Template & lt; Class derT> Structure A {A (DRT * PTR): M_PTR (PTR) {} // template & lt; Class T = empty_ & gt; Zero func () {m_ptr-> F (); } Private: derT * m_ptr; }; Structure B: Public A & LT; B & gt; {B (): A & lt; B & gt; (This) {} void f () {std :: cout & lt; & Lt; B: f: \ n ";}}; Structure C: Public A and LT; C & gt; {C:: A & lt; c & gt; (this) {} zero (g) () {std :: cout & lt; & lt; "c :: g \ n";}}; int main () {b b; cc; b.func (); cg (); // does not compile (as That is meaningless) because there is no function in cell C f () //c.func ();}
This works because function function is a template function, such as sfinee Takes care of the efficiency of the competent_i fi.
No comments:
Post a Comment