By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,017 Members | 1,077 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,017 IT Pros & Developers. It's quick & easy.

Using _t vs _type suffixes in typedefs

P: n/a
I'm wondering if theres any rationale behind using _t vs _type in
typedefs. I took a look in the standard and it doesn't say much
besides things like "size_type must be size_t", "difference_type must
be ptrdiff_t".

Looking at some libraries in Boost (Boost.GIL specifically) the
concepts describe types mainly using _type (value_type etc) but the
odd _t sneaks in there (const_t, layout_t).

One thing I notice is that _t is used more often with concrete types
whereas _type is used to re-declare template parameters etc. as its
something you usually want to pull out with scope resolution
(my_concrete_type<T>::value_type).

Any thoughts/opinions?

Cheers,
Chris

Jun 26 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Chris Fairles wrote:
I'm wondering if theres any rationale behind using _t vs _type in
typedefs. I took a look in the standard and it doesn't say much
besides things like "size_type must be size_t", "difference_type must
be ptrdiff_t".
I believe it's more of a nod in C direction. They use _t. 'size_t',
'ptrdiff_t', 'wchar_t' all are defined in C [as well]. It's easier
to have them named the same in the two related languages.

The C++ types that don't have counterparts in C (like 'size_type'
member of classes), don't have to be shortened.
Looking at some libraries in Boost (Boost.GIL specifically) the
concepts describe types mainly using _type (value_type etc) but the
odd _t sneaks in there (const_t, layout_t).
The 'value_type' typedef is part of the Standard containers.
One thing I notice is that _t is used more often with concrete types
whereas _type is used to re-declare template parameters etc. as its
something you usually want to pull out with scope resolution
(my_concrete_type<T>::value_type).

Any thoughts/opinions?
See above.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 26 '07 #2

P: n/a
Victor Bazarov wrote:
The C++ types that don't have counterparts in C (like 'size_type'
member of classes), don't have to be shortened.
It's also worth noticing that *_t is reserved by POSIX.
--
\|||/ Gennaro Prota - For hire
(o o) https://sourceforge.net/projects/breeze/
--ooO-(_)-Ooo----- (to mail: name . surname / yaho ! com)
Jun 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.