C++ Template meta-magic, template call-site qualification deduction mechanism -


I apologize for the interpretation of this example, I have emerged from a project, comment, item 1 and item two, The following codes are important.

  #include & lt; Boost / Intrusion / set.hpp & gt; Struct x: Public Promotion: Intrusion :: set_base_hook & lt; & Gt; {Int y; }; Structor Finder {Bull Operator () (Constant and I, Constance X and D X) Const {Return Returns & lt; _x.y;} Bull Operator () (Constant X & _x, Constite & amp; i) const {return _x.y & lt; I;}}; Class trampoline {public: zero bounce () constant / * item 1 * / {/ * item 2 * / boost :: intrusion :: set & lt; X & gt; :: iterator _set.find = (1, finder ()); Boost: Intrusion :: Set & lt; X & gt; _set; }; Int main () {Trumpolin T; T.bounce (); }   

I can not take a non-contact ricketer in my member container (item 2), where the function is constrained in the radius, if I switch the itater to a const_iterator then everything Works fine, or if I work with the attached function non-const it works well after the error of the following error message, after an hour of reverse engineering, it makes perfect sense:

< P> test.cc: "zero trampoline :: bounces (in member function) Constant ????: test.cc:21: Error: promote a ???? from: Intrusion :: do the tree_iterator & lt conversion; promotion :: intrusion :: rbtree_impl & lt; promotion :: infiltration :: setopt & lt; promotion :: intrusion :: expansion :: base_hook_traits & lt; x, boost :: intrusion :: rbtree_node_traits & lt; zero *, false & gt; (boost :: intrusion :: link_mode_type ) 1u, boost :: intrusion :: default_tag, 3>, std :: less than , long unsigned int, true & gt; & gt; true & gt; one ?? ?? a boost ???? non-scalar type :: intrusion :: Try_itertor & lt; Promotion :: Intrusion :: rbtree_impl & lt; Promotion :: Intrusion :: setopt & lt; Promotion :: Intrusion :: Extension :: base_hook_traits & LT; X, boost: intrusion :: rbtree_node_traits & lt; Zero *, false & gt; (boost :: intrusion :: link_mode_type) 1u, boost :: Intrusion :: default_tag, 3>, std :: less than < X>, long unsigned int, true & gt; & Gt;, false & gt; One ???? Requested

Which finally gave birth to the following template definition (/include/boost/intrusive/detail/tree_node.hpp +72):

  // /////////////////////////////////////////////// //////////////////////////////... Implementation of tree iterator // // //////// // ////////////////////////////////////////////// // /////////////////// // tree_iterator provides some basic functions for a // node oriented bidirectional iterator: the template & lt; Square Container, Boole IsConst & gt;   

It was so frustrating that I have solved this problem shortly ....

How to get this template IsConst Call of function attached to my brain is ready to explode (for everyone I know a bit simple, but I doubt it). Detailed explanation will be useful with a step from step-by-step implementation to explain mechanics.

I have the same question, which are similar in relation to type-cut / aliasing of the template system of C ++. Contexts are appreciated, but they need to be put into knowledge: D. If you have the patience to answer this question, then you would like to try to make a sermon on the second question.

What is the purpose of: : Intrusion :: Set does not work Just a const and a non-fixed overload? I mean, how do I do this:

  template & lt; Typename T / ... .. and & gt; Square set {// ... public: templates & lt; Bool isConst & gt; Class Iterator {// ....}; Iterator & LT; True & gt; Search (/*..*/) CONST; // Notice to the Constant I & lt; False & gt; looks like (/*..*/); // not notice const};   

This is not really magic of Meta programming, only good old fashion-tightness.

Comments