Term commonly used for the type defined within a type trait

87 views Asked by At

Let's define a type trait (we don't bother here about the actual definition of type):

template<typename T> struct sometrait  { using type = T; }; 

Question: is there a term commonly used for the type member of the struct that defines the trait ?

I guess that "type trait" should be used for the trait itself, so I'm not sure how to name type other than "the type defined within the type trait", which is a little bit tedious.

To clarify, I mean that a type trait often defines a conventional type member and I was wondering whether a conventional term specifically exist for it among the other member types of the trait.

1

There are 1 answers

0
user12002570 On

is there a term commonly used for the type member

In the standard, the term formally used for type is member typedef.

here I mean that a type trait often defines a conventional type member and I was wondering whether a conventional term specifically exist for it among the other member types of the trait.

If you have multiple member typedef then you call them just that. For example say you have one named type another named anothertype. Then you would call them like member typedef type and member typedef anothertype

template<typename T> struct sometrait  
{ 
    using type = T;        //member typedef type
    using type2 = const T; //member typedef type2
}; 

This is not any different from how we'd call multiple data members. Say we have 2 data members named a and b. Then we refer to them as data member a and data member b. Similarly, in the case of member typedef we would refer to them as member typedef a and member typedef b.