question about boost::ends_with



 DEVELOP > c-Plus-Plus > question about boost::ends_with

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Leo jay"
Date: 20 Oct 2006 03:09:15 AM
Object: question about boost::ends_with
following code is supposed to output 1, but in my vs2005, the output is
0.
if i change the "ends_with(str, sz)" into "ends_with(str, string(sz))",
the output is correct.
i wonder why. is there any difference between these two statement?
thanks.
// boosttest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <boost/algorithm/string.hpp>
#include <string>
#include <iostream>
using namespace boost;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char sz[1024] = "test.bat";
string str("C:\\test.bat");
cout << ends_with(str, sz) << endl;
return 0;
}
.

User: "mlimber"

Title: Re: question about boost::ends_with 20 Oct 2006 08:04:24 AM
Leo jay wrote:

following code is supposed to output 1, but in my vs2005, the output is
0.
if i change the "ends_with(str, sz)" into "ends_with(str, string(sz))",
the output is correct.
i wonder why. is there any difference between these two statement?

thanks.

// boosttest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <boost/algorithm/string.hpp>
#include <string>
#include <iostream>
using namespace boost;
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
char sz[1024] = "test.bat";
string str("C:\\test.bat");
cout << ends_with(str, sz) << endl;
return 0;
}

You should ask on the Boost Users list:
http://boost.org/more/mailing_lists.htm#users
Cheers! --M
.

User: "David Harmon"

Title: Re: question about boost::ends_with 20 Oct 2006 11:26:38 AM
On 20 Oct 2006 01:09:15 -0700 in comp.lang.c++, "Leo jay"
<Python.LeoJay@gmail.com> wrote,

following code is supposed to output 1, but in my vs2005, the output is
0.
if i change the "ends_with(str, sz)" into "ends_with(str, string(sz))",
the output is correct.
i wonder why. is there any difference between these two statement?

I don't know the whole answer to that, but I note that you will get
a different template expansion of ends_with<T1, T2>() in the two
cases. It's very possible for them to do different things, and it's
very different than if your char* was just converted to a string
argument.
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER