[c + + templates] Clang3.6 version of Checker

Source: Internet
Author: User

Clang3.6 version of Checker

one, the clang source code is as Follows:

template <typename check1, typename check2=check::_voidcheck,           typename check3=check::_voidcheck, typename check4=check::_ voidcheck,          typename check5=check::_voidcheck,  typename CHECK6=check::_VoidCheck,           typename check7=check::_voidcheck, typename check8=check::_voidcheck,           typename check9=check::_voidcheck, typename check10=check:: _voidcheck,          typename check11=check::_voidcheck , Typename check12=check::_voidcheck,          typename  CHECK13=check::_VoidCheck,typename CHECK14=check::_VoidCheck,           typename check15=check::_voidcheck,typename check16=check::_voidcheck,           typename check17=check::_voidcheck,typename check18=check::_ voidcheck,          typename check19=check::_voidcheck, Typename check20=check::_voidcheck,          typename  CHECK21=check::_VoidCheck,typename CHECK22=check::_VoidCheck,           typename CHECK23=check::_VoidCheck,typename CHECK24=check::_VoidCheck> Class checker;template <>class checker<check::_voidcheck>  : public  checkerbase{  virtual void anchor ();p ublic:  static void _ Register (void *checker, checkermanager &mgr)  { }};template <typename  check1, typename check2, typename check3, typename check4,           typename check5, typename check6, typename check7, typename check8,           typename check9, typename check10, typename check11,typename check12,           typename check13,typename check14,typename check15,typename check16,           typename check17,typename check18,typename check19, typename check20,          typename check21, typename check22,typename check23,typename check24>class checker     : public check1,      public checker<check2, check3 ,  check4, check5, check6, check7,                      CHECK8, CHECK9, CHECK10,CHECK11,CHECK12,CHECK13,                       CHECK14,CHECK15,CHECK16,CHECK17,CHECK18,CHECK19,                      check20,check21,check22,check23, Check24> {public:  template <typename checker>  static void  _register (checker *checker, checkermanager &mgr)  {    check1 :: _register (checker, mgr);    checker<check2, check3, check4,  check5, check6, check7,             Check8, check9, check10,check11,check12,check13,            check14,check15, check16,check17,check18,check19,             Check20,check21,check22,check23,check24>::_register (checker, mgr);  }};

second, the simulation realizes checker

Header file

/********************************                                                            ** Author : szyu** Date :  2016.12.27*********************************/#ifndef  __szyu_clang__#define __szyu_clang__#include  <iostream>class DefaultClass{public:    static void     _register ()     {            std::cout <<  "in defaultclass::_register ()"  << std::endl;     }   };class FunctionClass1{public:    static  Void    _registeR ()     {           std::cout  <<  "in functionclass1::_register ()"  << std::endl;    }}; Class functionclass2{public:    static void    _register ()     {        std::cout <<  "in  functionclass2::_register () " << std::endl;    }};class  Functionclass3{public:    static void    _register ()      {        std::cout <<  "in  Functionclass3::_register () " << std::endl;    }};template < typename t1, typename t2 = defaultclass, typename t3 =  Defaultclass>class checker;template <>class checker<defaultclass>{public:    static void     _register ()     {        std::cout <<   "in checker<defaultclass>::_register ()"  << std::endl;         defaultclass::_register ();    }};template <typename  T1, typename t2, typename t3>class checker : public t1, public  checker<t2, t3>{public:    static void    _ Register ()     {        std::cout <<   "in checker<t1, t2, t3>::_register ()"  << std::endl;         t1::_register ();         checker <t2, t3>::_register();    }}; #endif 

Test Cases

/********************************                                                                  ** Author  :  szyu** date : 2016.12.27*********************************/#include   "register.h" Voidtest1 () {    typedef checker<defaultclass> checker1;     checker1::_register ();    std::cout <<  "====================="   << std::endl;    typedef Checker<FunctionClass1> Checker2;     checker2::_register ();    std::cout <<  "========== =========== "&NBSP;&LT;&LT;&NBsp;std::endl;    typedef checker<functionclass1, functionclass2>  Checker3;    checker3::_register ();    std::cout <<  "= ==================== " << std::endl;    typedef Checker< Functionclass1, functionclass2, functionclass3> checker4;    checker4::_ Register ();    std::cout <<  "=====================" &NBSP;&LT;&LT;&NBSP;STD :: endl;} Intmain ( int argc, char *argv[] ) {    test1 ();     return 0;}


Execution results

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/8C/72/wKioL1hs51ahzycJAAOvGNASalE968.png "title=" screen shot 2017-01-04 20.14.38.png "alt=" wkiol1hs51ahzycjaaovgnasale968.png "/>




[c + + templates] Clang3.6 version of Checker

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.