<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hmm, if I do this it gives me another
      error:<br>
      <br>
      test.cpp:15:42: error: 'SmartPtrType' following the 'template'
      keyword does not refer to a template<br>
       ~SmartUnion()
      {m_sptr.SmartPtrType<T>::~SmartPtrType<T>(); }<br>
      <br>
      Again, g++ takes it without complaining.<br>
      <br>
      Since I noticed that my original attachment got scrubbed I am
      pasting the modified test program directly. Perhaps the context
      will help to sort things out:<br>
      <br>
      #include <memory><br>
      #include <string><br>
      using namespace std;<br>
      <br>
      //comment this in to see the compiler error<br>
      #define show_compiler_error 1<br>
      <br>
      template<typename T, template<class> class SmartPtrType =
      shared_ptr> <br>
      struct SmartUnion<br>
      {<br>
          SmartUnion() {new(&m_sptr) SmartPtrType<T>();}<br>
      <br>
      <br>
      #ifdef show_compiler_error<br>
       ~SmartUnion()
      {m_sptr.SmartPtrType<T>::~SmartPtrType<T>(); }<br>
      #else <br>
       typedef SmartPtrType<T> smartptr_type;<br>
        ~SmartUnion() {m_sptr.smartptr_type::~smartptr_type(); }<br>
      #endif<br>
           <br>
       union {    <br>
           SmartPtrType<T> m_sptr;<br>
           T * m_ptr;<br>
       };<br>
       <br>
      };<br>
      <br>
      using namespace std;<br>
      int main()<br>
      {<br>
          SmartUnion<string,shared_ptr> smu;<br>
              <br>
          return 0;<br>
      }<br>
      <br>
      <br>
      Am 08.10.2013 20:08, schrieb Richard Smith:<br>
    </div>
    <blockquote
cite="mid:CAOfiQqn4hOGZWupcuCOZDT00MViE5TjpxBJRte4rMzbiXYrdTA@mail.gmail.com"
      type="cite">
      <div dir="ltr">You need to write
        <div><br>
        </div>
        <div>  m_sptr.SmartPtrType<T>::~SmartPtrType<b><T></b>();<br>
          <div class="gmail_extra"><br>
          </div>
          <div class="gmail_extra">Per 3.4.3/6, "in a qualified-id of
            the form nested-name-specifier[opt] class-name::~class-name,
            the second class-name is looked up in the same scope as the
            first". So you can't use the injected-class-name after the
            ~, because it's not visible.</div>
          <div class="gmail_extra"><br>
            <div class="gmail_quote">On Tue, Oct 8, 2013 at 10:05 AM,
              Daniel Schwalbe <span dir="ltr"><<a
                  moz-do-not-send="true"
                  href="mailto:dansch491@gmail.com" target="_blank">dansch491@gmail.com</a>></span>
              wrote:<br>
              <blockquote class="gmail_quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div bgcolor="#FFFFFF" text="#000000">
                  <div>When I add the 'template' keyword as suggested
                    clang gives me the very same error. g++ still eats
                    it without problem.<br>
                    <br>
                    Am 08.10.2013 18:23, schrieb David Blaikie:<br>
                  </div>
                  <div>
                    <div class="h5">
                      <blockquote type="cite">
                        <div dir="ltr"><br>
                          <div class="gmail_extra"><br>
                            <br>
                            <div class="gmail_quote">On Tue, Oct 8, 2013
                              at 8:36 AM, Daniel Schwalbe <span
                                dir="ltr"><<a moz-do-not-send="true"
                                  href="mailto:dansch491@gmail.com"
                                  target="_blank">dansch491@gmail.com</a>></span>
                              wrote:<br>
                              <blockquote class="gmail_quote"
                                style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi,<br>
                                <br>
                                I don't know if I encountered a compiler
                                bug in clang 3.3 or if this is one of
                                the many subtle c++ exceptional cases:<br>
                                <br>
                                When I try to compile the attached file
                                (using: clang++ -std=c++11 test.cpp) I
                                receive a compiler error:<br>
                                <br>
                                "test.cpp:15:42: error: identifier
                                'SmartPtrType' in object destruction
                                expression does not name a type<br>
                                 ~SmartUnion()
                                {m_sptr.SmartPtrType<T>::~SmartPtrType();
                                }"<br>
                                <br>
                                g++ compiles the file without problem.<br>
                                <br>
                                clang compiles it, too, if I explicitly
                                introduce a typedef for
                                SmartPtrType<T> and call this
                                typedef name instead:<br>
                                <br>
                                typedef SmartPtrType<T>
                                smartptr_type;<br>
                                ~SmartUnion()
                                {m_sptr.smartptr_type::~smartptr_type();
                                }<br>
                                <br>
                                Is this a subtle language feature or a
                                compiler bug?</blockquote>
                              <div><br>
                              </div>
                              <div>I believe this is a language feature
                                because the expression is ambiguous if
                                m_sptr is type dependent (which I assume
                                it is)<br>
                                <br>
                                The other solution, rather than
                                introducing a typedef, is to use the
                                'template' keyword:<br>
                                <br>
                                ~SmartUnion() {m_sptr.template
                                SmartPtrType<T>::~SmartPtrType();
                                }<br>
                              </div>
                              <div> </div>
                              <blockquote class="gmail_quote"
                                style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><font
                                    color="#888888"><br>
                                    <br>
                                    Daniel<br>
                                    <br>
                                    <br>
                                    <br>
                                  </font></span><br>
_______________________________________________<br>
                                cfe-users mailing list<br>
                                <a moz-do-not-send="true"
                                  href="mailto:cfe-users@cs.uiuc.edu"
                                  target="_blank">cfe-users@cs.uiuc.edu</a><br>
                                <a moz-do-not-send="true"
                                  href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users"
                                  target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users</a><br>
                                <br>
                              </blockquote>
                            </div>
                            <br>
                          </div>
                        </div>
                      </blockquote>
                      <br>
                    </div>
                  </div>
                </div>
              </blockquote>
            </div>
            <br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>