Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-14141

Indirect partial specialization for pointer type doesn't work

    XMLWordPrintable

Details

    Description

      This looks like the final blocker for supporting stl iterators, at least the gcc implementation.

      Test added in CppTools,test_completion:pointer_partial_specialization.

      template<typename T>
      struct Traits { typedef typename T::pointer pointer; };
      
      template<typename _Tp>
      struct Traits<_Tp*> { typedef _Tp *pointer; };
      
      template<typename _Tp>
      struct IndirectT
      {
         typedef Traits<_Tp> TraitsT;
         typedef typename TraitsT::pointer pointer;
         pointer p;
      };
      
      template<typename T>
      class Temp
      {
      protected:
          typedef Traits<T> TraitsT;
          typedef T *TPtr;
      
      public:
          typedef typename TraitsT::pointer pointer;
          typedef IndirectT<pointer> indirect;
      
          pointer p;
          indirect i;
      };
      
      struct Foo { int bar; };
      
      class Temp2
      {
      protected:
          typedef Foo *FooPtr;
          typedef Traits<FooPtr> TraitsT;
      
      public:
          typedef typename TraitsT::pointer pointer;
      
          pointer p;
      };
      
      void func()
      {
          Temp<Foo *> t;
          Temp<Foo *>::indirect i;
          Temp2 t2;
          t.p->bar; // bar not highlighted
          i.p->bar; // bar not highlighted
          t2.p->bar; // bar not highlighted
      }

      My observation:

      ClassOrNamespace::nestedType receives unexpanded Traits<T>. Then when it tries to find a specialization, T (as opposed to Foo *) is not a pointer, so the specialization is not determined.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              orgads Orgad Shaneh
              orgads Orgad Shaneh
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: