473,461 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 4056
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? ...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.