As @MarcoA.'s answer correctly points out, the suffix _t
is largely inherited from C (and in the global namespace - reserved for POSIX).
This leaves us with "no suffix" and _type
.
Notice that there is no namespace-scope name in std
ending in _type
*; all such names are members of classes and class templates (or, in the case of regex-related types, of a nested namespace which largely plays a role of a class). I think that's the distinction: types themselves don't use the _type
suffix.
The suffix _type
is only used on members which denote types, and moreover, usually when they denote a type somewhat "external" to the containing class. Compare std::vector<T>::value_type
and std::vector<T>::size_type
, which come from the vector's template parameters T
and Allocator
, respectively, against std::vector<T>::iterator
, which is "intrinsic" to the vector class template.
* Not entirely true, there are a few such names (also pointed out in a comment by @jrok): common_type
, underlying_type
, is_literal_type
, true_type
, false_type
. In the first three, _type
is not really a suffix, it's an actual part of the name (e.g. a metafunction to give the common type or the underlying type). With true_type
and false_type
, it is indeed a suffix (since true
and false
are reserved words). I would say it's a type which represents a true/false value in the type-based metaprogramming sense.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…