Connecting Tech Pros Worldwide Help | Site Map

boost::lambda start learning

 
LinkBack Thread Tools Search this Thread
  #1  
Old October 30th, 2007, 03:05 PM
yurec
Guest
 
Posts: n/a
Default boost::lambda start learning

Hi
I start learning boost.Today I tried to use boost::lambda but failed
to compile very simple example.
2 hours of googling gave nothing.
Can anybody help me?

using namespace boost::lambda;

typedef std::map<int,std::string_ttype;
type test;
test[0] = (_T("1"));
test[1] = (_T("2"));
test[2] = (_T("3"));

std::vector<std::string_ttest_vector;

std::for_each(test.begin(),test.end(),

test_vector.push_back(bind(&type::value_type::seco nd,_1))
);

---------------------------------------------------------------------------------
: error C2664: 'std::vector<_Ty>::push_back' : cannot convert
parameter 1 from 'const boost::lambda::lambda_functor<T>' to 'const
std::string_t &'


  #2  
Old October 30th, 2007, 03:15 PM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: boost::lambda start learning

yurec wrote:
Quote:
I start learning boost.Today I tried to use boost::lambda but failed
to compile very simple example.
2 hours of googling gave nothing.
Can anybody help me?
>
using namespace boost::lambda;
>
typedef std::map<int,std::string_ttype;
I've never seen 'std::string_t', what is is? There is no mention
of 'string_t' in the Standard.
Quote:
type test;
test[0] = (_T("1"));
test[1] = (_T("2"));
test[2] = (_T("3"));
>
std::vector<std::string_ttest_vector;
>
std::for_each(test.begin(),test.end(),
>
test_vector.push_back(bind(&type::value_type::seco nd,_1))
);
>
---------------------------------------------------------------------------------
Quote:
>error C2664: 'std::vector<_Ty>::push_back' : cannot convert
parameter 1 from 'const boost::lambda::lambda_functor<T>' to 'const
std::string_t &'
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


  #3  
Old October 31st, 2007, 03:35 AM
=?iso-8859-1?q?Kirit_S=E6lensminde?=
Guest
 
Posts: n/a
Default Re: boost::lambda start learning

On Oct 30, 10:02 pm, yurec <Yurij.Zha...@materialise.kiev.uawrote:
Quote:
Hi
I start learning boost.Today I tried to use boost::lambda but failed
to compile very simple example.
2 hours of googling gave nothing.
Can anybody help me?
>
using namespace boost::lambda;
>
typedef std::map<int,std::string_ttype;
type test;
test[0] = (_T("1"));
test[1] = (_T("2"));
test[2] = (_T("3"));
Microsoft's _T hack doesn't really address any of the important issues
to do with going from narrow characters to wide characters. You're
normally better off just using wide characters if you think you'll
need them and narrow if you won't.
Quote:
>
std::vector<std::string_ttest_vector;
>
std::for_each(test.begin(),test.end(),
>
test_vector.push_back(bind(&type::value_type::seco nd,_1))
);
You need to do a double bind. Although bind you have isn't really to a
function, what you need to do is still function composition so you
need a double bind - the first to bind to type::value_type::second and
the second to bind to push_back.

Take a look at this generic composition example: http://www.boostcookbook.com/Recipe:/1234820
Quote:
---------------------------------------------------------------------------------
: error C2664: 'std::vector<_Ty>::push_back' : cannot convert
parameter 1 from 'const boost::lambda::lambda_functor<T>' to 'const
std::string_t &'
This is because you can't pass the functor you get from bind to
push_back as you're doing. You need to also bind push_back.


K

  #4  
Old October 31st, 2007, 04:55 AM
Wade Ward
Guest
 
Posts: n/a
Default Re: boost::lambda start learning


"Kirit Sælensminde" <kirit.saelensminde@gmail.comwrote in message
news:1193801172.814120.146730@z9g2000hsf.googlegro ups.com...
Quote:
On Oct 30, 10:02 pm, yurec <Yurij.Zha...@materialise.kiev.uawrote:
Quote:
>Hi
>I start learning boost.Today I tried to use boost::lambda but failed
>to compile very simple example.
>2 hours of googling gave nothing.
>Can anybody help me?
>>
>using namespace boost::lambda;
>>
> typedef std::map<int,std::string_ttype;
> type test;
> test[0] = (_T("1"));
> test[1] = (_T("2"));
> test[2] = (_T("3"));
>
Microsoft's _T hack doesn't really address any of the important issues
to do with going from narrow characters to wide characters. You're
normally better off just using wide characters if you think you'll
need them and narrow if you won't.
>
Quote:
>>
> std::vector<std::string_ttest_vector;
>>
> std::for_each(test.begin(),test.end(),
>>
>test_vector.push_back(bind(&type::value_type::sec ond,_1))
> );
>
You need to do a double bind. Although bind you have isn't really to a
function, what you need to do is still function composition so you
need a double bind - the first to bind to type::value_type::second and
the second to bind to push_back.
>
Take a look at this generic composition example:
http://www.boostcookbook.com/Recipe:/1234820
>
Quote:
>---------------------------------------------------------------------------------
>: error C2664: 'std::vector<_Ty>::push_back' : cannot convert
>parameter 1 from 'const boost::lambda::lambda_functor<T>' to 'const
>std::string_t &'
>
This is because you can't pass the functor you get from bind to
push_back as you're doing. You need to also bind push_back.
so nice to see. work along these lines that isn't mine.

Is it possible that c++ understands what a functor is?

--
wade ward

President
Merrill Jensen Consulting


wade@zaxfuuq.net
435 -838-7760


  #5  
Old October 31st, 2007, 07:25 AM
yurec
Guest
 
Posts: n/a
Default Re: boost::lambda start learning

On 31 , 06:45, "Wade Ward" <zaxf...@invalid.netwrote:
Quote:
"Kirit Sælensminde" <kirit.saelensmi...@gmail.comwrote in message
>
news:1193801172.814120.146730@z9g2000hsf.googlegro ups.com...
>
Quote:
On Oct 30, 10:02 pm, yurec <Yurij.Zha...@materialise.kiev.uawrote:
Quote:
Hi
I start learning boost.Today I tried to use boost::lambda but failed
to compile very simple example.
2 hours of googling gave nothing.
Can anybody help me?
>
Quote:
Quote:
using namespace boost::lambda;
>
Quote:
Quote:
typedef std::map<int,std::string_ttype;
type test;
test[0] = (_T("1"));
test[1] = (_T("2"));
test[2] = (_T("3"));
>
Quote:
Microsoft's _T hack doesn't really address any of the important issues
to do with going from narrow characters to wide characters. You're
normally better off just using wide characters if you think you'll
need them and narrow if you won't.
>
Quote:
Quote:
std::vector<std::string_ttest_vector;
>
Quote:
Quote:
std::for_each(test.begin(),test.end(),
>
Quote:
Quote:
test_vector.push_back(bind(&type::value_type::seco nd,_1))
);
>
Quote:
You need to do a double bind. Although bind you have isn't really to a
function, what you need to do is still function composition so you
need a double bind - the first to bind to type::value_type::second and
the second to bind to push_back.
>
Quote:
Take a look at this generic composition example:
http://www.boostcookbook.com/Recipe:/1234820
>
Quote:
Quote:
---------------------------------------------------------------------------*------
: error C2664: 'std::vector<_Ty>::push_back' : cannot convert
parameter 1 from 'const boost::lambda::lambda_functor<T>' to 'const
std::string_t &'
>
Quote:
This is because you can't pass the functor you get from bind to
push_back as you're doing. You need to also bind push_back.
>
so nice to see. work along these lines that isn't mine.
>
Is it possible that c++ understands what a functor is?
>
--
wade ward
>
President
Merrill Jensen Consulting
>
w...@zaxfuuq.net
435 -838-7760
Ok, thanks to everybody, I work with it a little more , understand
better and now everyting is ok.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.