473,387 Members | 1,897 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,387 software developers and data experts.

What is a Traits class

mythescriptid
Hi,

I'm trying to understand what a Traits class and when/how it is used. I have read some definitions on different sites but failed to understand the real use ;(!. Can someone explain with a simple definition and example please.

Thanks in advance.

Hari
May 28 '07 #1
4 1960
sicarie
4,677 Expert Mod 4TB
Hi,

I'm trying to understand what a Traits class and when/how it is used. I have read some definitions on different sites but failed to understand the real use ;(!. Can someone explain with a simple definition and example please.

Thanks in advance.

Hari
Just as a guess based off the name, I would guess that it is a class that contains "traits" of another object - or methods that would affect how it behaved. Is this what you thought, or is there a specific "Traits" class I'm unaware of?
May 29 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
The STL traits class is the type used to specialize the STL template. So, char or int, etc. are traits. The STL templates use a traits rather than a T. By doing this, you can code traits methods for your type, which you cannot do with a simple placeholder like T.
May 29 '07 #3
sicarie
4,677 Expert Mod 4TB
Thanks weaknessforcats, as you can tell, I definitely did not know that.
May 29 '07 #4
AdrianH
1,251 Expert 1GB
Look up SFINAE (Substitution Error Is Not An Error) for more information.


Adrian
May 29 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Donald 'Paddy' McCarthy | last post by:
Hi, I am having a few problems with a GUI. I am new to traits and wxGlade. I have used wxGlade to create a Form with an embedded space for a CustomWidget. I have the traits demo and would like...
4
by: Alexander Stippler | last post by:
Hi, I want to use a different Konstruktor to initialize an array depending on the type of objects stored. I guess it has something to do with accolator traits, but I'm not quite sure how to...
5
by: Rex_chaos | last post by:
Hi there, I am learning template programming and there is a problem about traits. Now consider a container and an iterator. Here is the code // tag for const iterator and non-const iterator...
12
by: Mark A. Gibbs | last post by:
Good day, What is the safest way to get a non-end of file value? char_traits<char_type>::eof() will get me eof, but how can I safely and consistently generate a value that is not eof? should i...
4
by: Sargon | last post by:
Hi I have a problem with C++ traits. The following lil program provides a Wrapper class which contains 3 static methods. (1 normal, 2 as a template)...
3
by: Raider | last post by:
I'm trying to create a base class who will contain generic algoritms and derived class(es) who will perform problem-specific things. I'm unable to use dynamic polymorphism, because base class know...
9
by: Bit Byte | last post by:
Can't seem to get my head around the point of a trait class - no matter how many times I read up on it - why not simply use functors or function pointers ? Anyone care to explain this in a...
4
by: Vince C. | last post by:
Hi all. I can see the standard template library has changed a lot since I begun C++ 10 years ago... Now I'm facing with outputing the members of a struct, say Option, which contains 2 members...
2
by: Colin J. Williams | last post by:
Using >easy_install -v -f http://code.enthought.com/enstaller/eggs/source enthought.traits The result is: .... many lines ....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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$) { } ...
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
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.