c++ - terminology or design pattern name -


i reading source code in there class definition follows:

template<typename t> class c {     ...     t * func() {         const_cast<c *>(this)->somefunc();         ...     } }; 

i unable understand philosophy or purpose of syntax. , application of such code? know formal terminology/definition or design pattern same.

edit:

somefunc() implemented follows:

void somefunc() {     anotherfunc(*this); } 

and anotherfunc() is:

template<typename t> inline void anotherfunc(c<t> & a) {     throw std::runtime_error(std::string("blah blah blah")                              + typeid(t).name()); } 

then within code there classes like:

class f {     func_1();     func_2();     func_3(); } 

c instantiated this:

c<f> inst; 

then functions within f accessed inst->func_1();.

if 1 aiming redirect api use existing api, without forcing client change code.

if provide more context about

  • somefunc() declaration.
  • any class hierarchy.

to identify real need.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -