Home How to read this template class in C++?
Reply: 0

How to read this template class in C++?

Sitram
1#
Sitram Published in 2018-01-10 14:47:34Z

I recently started working together with some more experience colleagues on refactoring a C++ project. I found this template class added by someone from the team which I don't really understand. I have limited experience with templates in C++ so maybe someone with more experience can explain how to read this code.

class Base {
}

template<typename> class ShellBase;

  template<typename I, typename O,
    template<typename, typename> class DT,
    template<typename> class CMP>
  class ShellBase<CMP<DT<I, O>>> : public Base
  {

   public :

   boolean exec(
   DT<I, O>& param1,
   BaseClass1& param2,
   BaseClass2& param3);

   CMP<DT<I, O>> m_component;
  }

Body of ShellBase<>::exec method

template<typename I, typename O, 
        template<typename, typename> class DT,
        template<typename> class CMP>
boolean ShellBase<CMP<DT<I,O>>>::exec
    (DT<I, O>& param1, BaseClass1& param2, BaseClass2& param3)
 {
  boolean ret = false;
  const Mode& mode = param2.getMode();
  switch (mode )
  {
  case 1:
    {
      m_component.exec1(param1, param2); 
      ret = true;
      break;
    }
  ...
  default:
    {
      ret  = false;
    }
  }
  return ret ; 
}

EDIT: Removed the request for documentation on C++ templates because someone said is against SO rules.

Thank you,

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.347273 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO