[cfe-dev] template typedef

John McCall rjmccall at apple.com
Tue Mar 16 14:16:10 PDT 2010


On Mar 16, 2010, at 2:10 PM, Jochen Wilhelmy wrote:

> Hi!
> 
> would it be possible to add a non-standard extension for template typedefs?
> 
> e.g.
> template <typename Type>
> 
> typedef Type __attribute__((ext_vector_type(4))) Vector4;
> 
> 
> Vector4<float> myFloatVector;
> 
> 
> or other example:
> 
> template <typename Type>
> typedef std::map MyMap;
> 
> MyMap<int> myMap;

You'd be surprised at how of the language this would effect;  if you put the work into supporting it properly, I don't think we'd accept such a change in mainline.

You can get a similar effect with typedef members of class templates, though:

  template <typename T> class Vector4 {
    typedef T __attribute__((ext_vector_type(4))) type;
  };

  Vector4<float>::type myFloatVector;

I believe this should even work in clang ToT.

John.



More information about the cfe-dev mailing list