Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Jul 24th, 2005, 6:34 AM   #11
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Quote:
The problem posted by OP is so simple -- Forget about using all those other complex templates that do nothing more than make the solution to the problem more complicated
I think boost is a bit of an overkill here, when my function does precisely what is needed and has the added benefit of the separator token being a std::string, not a single char. With that said, he wanted it split into an "array", not just printed to stdout, so you'll need to store the values in an array-like container, which std::vector is.
Cerulean is offline   Reply With Quote
Old Jul 24th, 2005, 7:24 AM   #12
Shapeless
Programmer
 
Shapeless's Avatar
 
Join Date: Jul 2005
Location: germany/hamburg
Posts: 32
Rep Power: 0 Shapeless is on a distinguished road
Send a message via ICQ to Shapeless Send a message via MSN to Shapeless
I am sorry cerulean, but i think you (and maybe the others) didnt understand the code.
Quote:
I think boost is a bit of an overkill here
1) i think you have no idea the code intern looks like!
Quote:
and has the added benefit of the separator token being a std::string, not a single char
my function has the benifit to every kind of predecate!!!!
boost::is_any_of(""); is only one example
you could also use std::eqal and many more
you can implement every other kind of predecate yourself!!!
or to work on non-char delimters you also could use boost::tokenizer

Quote:
With that said, he wanted it split into an "array", not just printed to stdout, so you'll need to store the values in an array-like container, which std::vector is.
the function split gets a reference to the result container! so the vector<std::string> result holts the result, like your did. and u also could use EVERY other container which can hold a type convertable to the string!
sorry the std::copy function is just an additional output. here is the code again!


#include<string>
#include<vector>
#include<boost/algorithm/string.hpp>
int main() {
	std::vector<std::string> res;
	boost::split(res,"hallo-this-is-a-string",boost::is_any_of("-"));
}

I am sorry but if somebody doesnt understand some code he should't start talking about its correctness....

Quote:
The problem posted by OP is so simple -- Forget about using all those other complex templates that do nothing more than make the solution to the problem more complicated. You guys are making such a complicated solution out of something that is very trivel
do u really think my solution is complicated? what does that mean?
using a function that exactly does what somebody asks for is complicated?
of is the handling of
function(param1,param2.param3) too complicated?
i think u really didnt understand! the author doesnt need to do anything but use the function.. thats really not a conplicated thing...
whats your prob with templates ? I think its one of the most powerfull things in c++ and you just dislike them or something.... I am sorry but this solutions is fast,optimized ( written by very good designers and coders) and really easy and intuitive to use.... sorry but i really didnt get your point...
but if u think this whole thing is to complicated and a huge overhead then u also should stop using the string,vector,.... the whole stl... and you should also programm in c instead of c++...
Quote:
Get real.
I am ... but if you think it wont be like that please tell me why u think that !
its already decided that some boost thinkgs are in the next c++ standart and the string algo and regex things are candidates ... so what do you think about this.
__________________
of all the things he has lost, i think he misses his mind the most

typedef typename pizza_t<oven_policy<225,12.5>,ingredient_policy<salami,mushroom,cheese> > Pizza;
Shapeless is offline   Reply With Quote
Old Jul 24th, 2005, 7:47 AM   #13
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 529
Rep Power: 4 Ancient Dragon is on a distinguished road
Quote:
Originally Posted by Shapeless
do u really think my solution is complicated? what does that mean?
Yes because I shutter and close my eyes every time I see a template I hate them so much I refuse to code them myself -- I'll use those from STL because I don't have to actually read them to use them. The boost library examples you posted is totally beyond my comprehension.
Ancient Dragon is offline   Reply With Quote
Old Jul 24th, 2005, 1:00 PM   #14
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Quote:
1) i think you have no idea the code intern looks like!
Regardless. Boost is a library which I very much love (especially Boost:ython), but for something like this I don't think it's needed. It is a large library.

Quote:
the function split gets a reference to the result container!
That was in reference to Ancient Dragon's sample, not yours. I'm quite aware of what boost::split does
Cerulean is offline   Reply With Quote
Old Jul 24th, 2005, 1:10 PM   #15
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 529
Rep Power: 4 Ancient Dragon is on a distinguished road
Quote:
Originally Posted by Cerulean
With that said, he wanted it split into an "array", not just printed to stdout, so you'll need to store the values in an array-like container, which std::vector is.
I assumed, maybe wrongly, that the op had enough sense to figure that part out for himself.
Ancient Dragon is offline   Reply With Quote
Old Jul 24th, 2005, 2:26 PM   #16
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Heh, I was just referring to the following:
Quote:
Forget about using all those other complex templates that do nothing more than make the solution to the problem more complicated.
And thought that you meant using a vector.
Cerulean is offline   Reply With Quote
Old Jul 24th, 2005, 9:36 PM   #17
Shapeless
Programmer
 
Shapeless's Avatar
 
Join Date: Jul 2005
Location: germany/hamburg
Posts: 32
Rep Power: 0 Shapeless is on a distinguished road
Send a message via ICQ to Shapeless Send a message via MSN to Shapeless
Quote:
Originally Posted by Cerulean
Regardless. Boost is a library which I very much love (especially Boost:ython), but for something like this I don't think it's needed. It is a large library.
That was in reference to Ancient Dragon's sample, not yours. I'm quite aware of what boost::split does
ok, but i wasnt able to figure out that that didnt meant me.
well the boost libs are sometimes big, and but you are able to include just a few parts. but i think the perfomance and overhead-argument is understandable, as u can see by the size of the binary. but sometimes this resources are not the limiting fact so its always good to know about the libs that are usable, but i have to admit thats its never wrong to write an own solution if a lib would be an overhead. and sometimes u have to do that and in other cases its just like there is just a little overhead, or you have to focus on another implementation level and so u could/should use a lib..

greets
__________________
of all the things he has lost, i think he misses his mind the most

typedef typename pizza_t<oven_policy<225,12.5>,ingredient_policy<salami,mushroom,cheese> > Pizza;
Shapeless 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 2:32 AM.

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