a question about GenScatterHierarchy class

2006-10-27
2013-04-08
  • Nobody/Anonymous

    Hi, all:
           in GenScatterhierarchy class implementation, I noticed that

            template <class T1, class T2, template <class> class Unit>
        class GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit>
            : public GenScatterHierarchy<T1, Unit>
        {
        };
    this template class has been derived from GenScatterHierarchy<T1, Unit> template class

    why wasn't directly derived from Unit<T1>, just as follows:

        template <class T1, class T2, template <class> class Unit>
        class GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit>
            : public Unit<T1>
        {
        };

    since one of purposes of GenScatterHierarchy is applying every element in the typelist to Unit template class, why  wasn't just straightfoward Derived from Unit<T1>?if it was straightly  derived from Unit<T1>,
    then the following template class would  never  be  necessary any more.

        template <class AtomicType, template <class> class Unit>
        class GenScatterHierarchy : public Unit<AtomicType>
        {
            typedef Unit<AtomicType> LeftBase;
            template <typename T> struct Rebind
            {
                typedef Unit<T> Result;
            };
        };

    I'm so confused!~

    Best Wishes,
                                                 minggang.xu
                                                 2006/10/27 China HangZhou

     
    • Fraser

      Fraser - 2009-08-25

      template <typename AtomicType, typename T2, template <typename> class Unit> 
      class GenScatterHierarchy<Private::ScatterHierarchyTag<AtomicType, T2>, Unit> 
      : public Unit<AtomicType> 

      public:
      typedef Unit<AtomicType> LeftBase; 
      }; 

      I made the typedef public.  Its strange that it compiles as it was.  Actually theres too many public members.  GenScatterHierarchy should have friends instead of the public members.

      FieldHelper should be in namespace Private.

       
    • Fraser

      Fraser - 2009-08-27

          template
          <
              template <class, class> class Unit,
              class Root
          >
          class GenLinearHierarchy<NullType , Unit, Root>
              : public Root // is this better: Unit<NullType, Root> ?
          {
          };
      This class is not doing anything.

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks