Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 8th, 2006, 1:56 AM   #1
sharadpro
Newbie
 
Join Date: Feb 2006
Location: India
Posts: 25
Rep Power: 0 sharadpro is on a distinguished road
Difference : STL and Standard library

What is the difference between C++'s Standard Library and Standard Template Library?
sharadpro is offline   Reply With Quote
Old Oct 8th, 2006, 3:37 AM   #2
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 319
Rep Power: 4 andro is on a distinguished road
Send a message via AIM to andro
The Standard Template Library makes up a large part of the Standard Library.
andro is offline   Reply With Quote
Old Oct 11th, 2006, 12:35 AM   #3
sarumont
Hobbyist Programmer
 
sarumont's Avatar
 
Join Date: Apr 2004
Location: /dev/urandom
Posts: 154
Rep Power: 5 sarumont is on a distinguished road
Send a message via ICQ to sarumont Send a message via AIM to sarumont Send a message via Yahoo to sarumont
The biggest difference is that the STL uses templates (hence the T) to provide some more advanced data structures. These data structures are type-agnostic, a benefit derived from templates.
__________________
"Time is an illusion. Lunchtime doubly so."
-the late, great Douglas Adams
sarumont is offline   Reply With Quote
Old Oct 11th, 2006, 8:30 AM   #4
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5 grumpy will become famous soon enough
Quote:
Originally Posted by sarumont View Post
The biggest difference is that the STL uses templates (hence the T) to provide some more advanced data structures.
That's has an element of truth, but is not really that true. The use of templates in the STL makes the containers, algorithms, etc applicable to a wide range of data types. The sorts of data structures used in the STL are, at heart, no different from data structures supported by most modern programming language.

And there is much more to the STL than data structures.
Quote:
Originally Posted by sarumont View Post
These data structures are type-agnostic, a benefit derived from templates.
The STL is not type agnostic; it is better described as type generic. It is designed so it works with a wide range of types. But those types have to obey certain rules.

For example, there are various conditions that a type, X, must satisfy before a std::vector<X> can be declared and used. One of those conditions is that X must be copyable (eg it is a basic type, or a class with a valid copy constructor and assignment operator). Similarly, there are certain conditions that must be met for algorithms in the STL to work. For example, the std::sort() algorithm requires that the type it works with can be compared by value (to determine if x1 < x2 or not).
grumpy is offline   Reply With Quote
Old Oct 11th, 2006, 9:59 AM   #5
sarumont
Hobbyist Programmer
 
sarumont's Avatar
 
Join Date: Apr 2004
Location: /dev/urandom
Posts: 154
Rep Power: 5 sarumont is on a distinguished road
Send a message via ICQ to sarumont Send a message via AIM to sarumont Send a message via Yahoo to sarumont
Quote:
Originally Posted by grumpy View Post
That's has an element of truth, but is not really that true. The use of templates in the STL makes the containers, algorithms, etc applicable to a wide range of data types. The sorts of data structures used in the STL are, at heart, no different from data structures supported by most modern programming language.

And there is much more to the STL than data structures.
I should have added "and many related algorithms" to that. A container is, in fact, a data structure itself.

Quote:
Originally Posted by SGI
The Standard Template Library, or STL, is a C++ library of container classes, algorithms, and iterators; it provides many of the basic algorithms and data structures of computer science. The STL is a generic library, meaning that its components are heavily parameterized: almost every component in the STL is a template. You should make sure that you understand how templates work in C++ before you use the STL.
Iterators are also a big addition in the STL that I neglected to mention. My main point, though, was that most everything in the STL is generic. The provided algorithms and features (such as iterators) tend to lend themselves to the containers provided (as well as those you can build yourself using templates).

Quote:
Originally Posted by grumpy
The STL is not type agnostic; it is better described as type generic. It is designed so it works with a wide range of types. But those types have to obey certain rules.
Yes, generic is the better term. I was thinking more toward C++-provided types, but user-defined types must definitely be obedient to the rules that you have provided (and possibly more), depending on what algorithms you use from the STL.

Once again, the biggest point of difference here is the generic nature of the STL-provided algorithms, data structures and constructs.
__________________
"Time is an illusion. Lunchtime doubly so."
-the late, great Douglas Adams
sarumont is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:21 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC