Click here to Skip to main content
15,923,852 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: STL Algorithms Pin
Stuart Dootson12-Sep-06 22:17
professionalStuart Dootson12-Sep-06 22:17 
GeneralRe: STL Algorithms Pin
Zac Howland13-Sep-06 3:15
Zac Howland13-Sep-06 3:15 
GeneralRe: STL Algorithms Pin
Kevin McFarlane13-Sep-06 4:11
Kevin McFarlane13-Sep-06 4:11 
AnswerRe: STL Algorithms Pin
Steve Echols12-Sep-06 21:29
Steve Echols12-Sep-06 21:29 
GeneralRe: STL Algorithms Pin
Stephen Hewitt12-Sep-06 22:27
Stephen Hewitt12-Sep-06 22:27 
GeneralRe: STL Algorithms Pin
Zac Howland13-Sep-06 3:24
Zac Howland13-Sep-06 3:24 
GeneralRe: STL Algorithms Pin
Stephen Hewitt13-Sep-06 14:14
Stephen Hewitt13-Sep-06 14:14 
GeneralRe: STL Algorithms Pin
Zac Howland13-Sep-06 18:32
Zac Howland13-Sep-06 18:32 
Stephen Hewitt wrote:
Michael Dunn's objection to STL: having to write a "one off" functor.


You don't have to write a functor to use for_each, nor most of the other algorithms. Using your own example (and by the way, your for_each example actually does nothing but waste CPU cycles as written), the following works perfectly fine:

template<class T> T square_plus_one(const T& i)
{
	return (i * i + 1);
}

int main()
{
	vector<int> intVec;
	// fill vector here
	transform(intVec.begin(), intVec.end(), intVec.begin(), square_plus_one<int> ) ;

	return 0;
}


Granted, the Lamda library makes this even easier, and I fully support the use of it. However, for most common loops, this really isn't that complex.

Stephen Hewitt wrote:
What's not true? If I want to see if I get better performance or use less memory using a std::list I simply change one line - this is a fact. Not many people will think it's better to have to make multiple scattered changes and run the risk of introducing an error somewhere along the way. If you've got a specific point make it here as opposed to referring to a book but giving no clue to what to mean.


What I meant is that the containers are not completely interchangible. For some simple things such as iterating through them, they are designed to be the same to make use of the algorithms. However, things like insertion, deletion, allocation of space, etc ... many of them are different (have different function names, don't have certain functions, etc). I directed you to the book because he gives a much better explanation that I could hope to offer on this forum (at least without plaugerizing the book).



If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

GeneralRe: STL Algorithms [modified] Pin
Stephen Hewitt13-Sep-06 19:32
Stephen Hewitt13-Sep-06 19:32 
GeneralRe: STL Algorithms Pin
Zac Howland14-Sep-06 3:13
Zac Howland14-Sep-06 3:13 
GeneralRe: STL Algorithms Pin
Stephen Hewitt14-Sep-06 13:50
Stephen Hewitt14-Sep-06 13:50 
GeneralRe: STL Algorithms Pin
Zac Howland14-Sep-06 19:17
Zac Howland14-Sep-06 19:17 
GeneralRe: STL Algorithms Pin
Stephen Hewitt14-Sep-06 19:27
Stephen Hewitt14-Sep-06 19:27 
GeneralRe: STL Algorithms Pin
Zac Howland13-Sep-06 3:21
Zac Howland13-Sep-06 3:21 
AnswerRe: STL Algorithms Pin
Kevin McFarlane13-Sep-06 4:08
Kevin McFarlane13-Sep-06 4:08 
GeneralRe: STL Algorithms Pin
Zac Howland13-Sep-06 4:23
Zac Howland13-Sep-06 4:23 
GeneralRe: STL Algorithms Pin
Kevin McFarlane13-Sep-06 9:01
Kevin McFarlane13-Sep-06 9:01 
GeneralRe: STL Algorithms Pin
Zac Howland13-Sep-06 9:17
Zac Howland13-Sep-06 9:17 
AnswerRe: STL Algorithms Pin
Stephen Hewitt13-Sep-06 22:52
Stephen Hewitt13-Sep-06 22:52 
GeneralRe: STL Algorithms Pin
Rob Caldecott13-Sep-06 23:40
Rob Caldecott13-Sep-06 23:40 
GeneralRe: STL Algorithms Pin
Stuart Dootson14-Sep-06 1:17
professionalStuart Dootson14-Sep-06 1:17 
GeneralRe: STL Algorithms Pin
Zac Howland14-Sep-06 3:17
Zac Howland14-Sep-06 3:17 
GeneralRe: STL Algorithms Pin
Nemanja Trifunovic15-Sep-06 4:43
Nemanja Trifunovic15-Sep-06 4:43 
GeneralRe: STL Algorithms Pin
Zac Howland15-Sep-06 5:26
Zac Howland15-Sep-06 5:26 
GeneralRe: STL Algorithms Pin
Stuart Dootson15-Sep-06 5:43
professionalStuart Dootson15-Sep-06 5:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.