473,385 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Using _t vs _type suffixes in typedefs

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
2 4053
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: dogu | last post by:
I'm missing something and need a push in the right direction. If I create a php file with the following content, and call it via a browser, it works as expected. <?php echo "hello world"; ?> ...
2
by: Levent | last post by:
Please consider the following Parent and Child template classes: template <class T> class Parent { public: typedef T type; typedef T& ref; /* pack of typedefs */ };
9
by: bubbakittee | last post by:
I am designing a package of functions to be used by people with very little programming experience (if any) and very little patience. I don't want to scare them with programmerish words like...
3
by: pyramus | last post by:
I am wondering which one should be preferred for creating a local synonym within a function definition. Let's say I have a type in my library called MyLib::Foundation::int32, which I can't stand...
30
by: junky_fellow | last post by:
I was looking at the source code of linux or open BSD. What I found that lots of typedefs were used. For example, consider the offset in a file. It was declared as off_t offset; and off_t is...
12
by: CQ | last post by:
Hi there, I am having the following problem: I have the following class: class reachGraphState { protected: /* ... some stuff .... */ public:
24
by: hammer1234 | last post by:
Hi I am wondering if there is a way of using the underlying bit representations of floats. I am interested in creating a violation in MISRA C:2004 of rule "The underlying bit representations...
7
by: Noah Roberts | last post by:
I have something like the following: template<ENUM X, int I = 0> class Generic { .... }; typedef Generic<Val1> v1_type; typedef Generic<Val2> v2_type;
1
by: pauldepstein | last post by:
While reading some source code, I saw a variable called "end" of type "time". So I investigated what the type "time" meant and saw that time was a typedef for "Real". So what does "Real" mean? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.