This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

unnamed namespaces and specializations


I would dearly love it if this code below is valid. 

I'm getting conflicting reports: g++ says no, icc says yes. I'm not
quite certain myself, after reading 7.3.1.1 - Unnamed namespaces  and
the other bits.

Thoughts?

%g++ -c namespace_issues_3.cc
namespace_issues_3.cc:32: error: specializing `class
   std::<unnamed>::vector<useless>' in different namespace
namespace_issues_3.cc:9: error:   from definition of `template<class _T> class
   std::<unnamed>::vector'

-benjamin



namespace std
{
  namespace
  {
    template<typename _T>
    class vector
    {
    public:
      int foo() { return 5; }
    };
  }
}

struct useless { };

// Want to specialize here.
namespace std 
{
   template<>
     class vector<useless> 
     { 
     public:
       int foo() { return 7; }
     };
}

int main()
{
  std::vector<useless> v;
  int i = v.foo();

  return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]