Click here to Skip to main content
15,890,512 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: std::string - HELP Pin
LCI25-Jul-05 4:35
LCI25-Jul-05 4:35 
GeneralRe: std::string - HELP Pin
Roland Pibinger25-Jul-05 13:08
Roland Pibinger25-Jul-05 13:08 
GeneralRe: std::string - HELP Pin
Rob Caldecott26-Jul-05 21:08
Rob Caldecott26-Jul-05 21:08 
GeneralRe: std::string - HELP Pin
Kevin McFarlane30-Jul-05 23:38
Kevin McFarlane30-Jul-05 23:38 
GeneralRe: std::string - HELP Pin
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX31-Jul-05 23:46
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX31-Jul-05 23:46 
GeneralRe: std::string - HELP Pin
Kevin McFarlane1-Aug-05 7:21
Kevin McFarlane1-Aug-05 7:21 
GeneralRe: std::string - HELP Pin
Nemanja Trifunovic1-Aug-05 8:12
Nemanja Trifunovic1-Aug-05 8:12 
GeneralRe: std::string - HELP Pin
Kevin McFarlane1-Aug-05 23:04
Kevin McFarlane1-Aug-05 23:04 
Sloppy Joseph wrote:
You search only for " ", not for white space (e.g. '\t')


Actually it does handle '\t', as I've only specified a default argument.

Sloppy Joseph wrote:
find_last_not_of() returns npos when no match is found (which is not an appropriate input for erase)

Agreed, but still seems to work anyway.


Sloppy Joseph wrote:
You return by value thus duplicating the string unnecessarily.

OK, how about this?

inline string& trim(string& s, const string& t)
{
	string::size_type st1, st2;
	st1 = s.find_first_not_of(t);
	
	if (st1 != string::npos)
	{
		st2 = s.find_last_not_of(t) + 1;
		s = s.substr(st1, st2 - st1);
	}
	else
	{
		s.clear();
	}

	return s;
}


Kevin
GeneralRe: std::string - HELP Pin
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX2-Aug-05 2:19
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX2-Aug-05 2:19 
GeneralRe: std::string Pin
Igor Vigdorchik25-Jul-05 9:27
Igor Vigdorchik25-Jul-05 9:27 
Generalusing auto_ptr Pin
kramkrish21-Jul-05 1:17
kramkrish21-Jul-05 1:17 
GeneralRe: using auto_ptr Pin
Nish Nishant21-Jul-05 1:41
sitebuilderNish Nishant21-Jul-05 1:41 
GeneralRe: using auto_ptr Pin
Nish Nishant21-Jul-05 1:43
sitebuilderNish Nishant21-Jul-05 1:43 
GeneralRe: using auto_ptr Pin
kramkrish22-Jul-05 3:46
kramkrish22-Jul-05 3:46 
GeneralRe: using auto_ptr Pin
Jörgen Sigvardsson23-Jul-05 3:21
Jörgen Sigvardsson23-Jul-05 3:21 
GeneralRe: using auto_ptr Pin
Nish Nishant23-Jul-05 4:31
sitebuilderNish Nishant23-Jul-05 4:31 
GeneralBUG: ATL 7.0 fails if chunk size is 07ff (2047 bytes) Pin
arun140520-Jul-05 4:54
arun140520-Jul-05 4:54 
GeneralImporting foreign types in IDL File Pin
morenz19-Jul-05 6:49
morenz19-Jul-05 6:49 
GeneralRe: Importing foreign types in IDL File Pin
morenz20-Jul-05 0:54
morenz20-Jul-05 0:54 
GeneralPlz give me some advice about my code (IE Programming/ATL/COM/MFC) Pin
19-Jul-05 3:10
suss19-Jul-05 3:10 
GeneralRe: Plz give me some advice about my code (IE Programming/ATL/COM/MFC) Pin
Douglas Troy19-Jul-05 7:00
Douglas Troy19-Jul-05 7:00 
GeneralRe: Plz give me some advice about my code (IE Programming/ATL/COM/MFC) Pin
Member 212103819-Jul-05 17:25
Member 212103819-Jul-05 17:25 
GeneralATLSTR.H & SHOBJIDL.H not found Pin
TOMCAT8118-Jul-05 20:20
TOMCAT8118-Jul-05 20:20 
GeneralRe: ATLSTR.H & SHOBJIDL.H not found Pin
Douglas Troy19-Jul-05 6:43
Douglas Troy19-Jul-05 6:43 
GeneralRe: ATLSTR.H & SHOBJIDL.H not found Pin
TOMCAT8120-Jul-05 22:24
TOMCAT8120-Jul-05 22:24 

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.