template typedef

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

template typedef

Jochen Wilhelmy
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;


-Jochen

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: template typedef

John McCall

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.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: template typedef

Douglas Gregor
In reply to this post by Jochen Wilhelmy

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;

We would not accept such an extension into mainline. C++0x has template aliases, which serve the same purpose but have not yet been implemented. See, e.g.,

        http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf

And the most recent C++0x working paper.

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev