Jump to content
  • Advertisement
Sign in to follow this  

Yet another boost lambda question

This topic is 4371 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For the following code, why (*) doesn't work?
using namespace std;
using namespace boost::lambda;
string p1("Hello");
string p2("World");
string s = (_1 + _2)(p1, p2);    // can't compile(*)
bool b = (_1 < _2)(p1, p2);    // compile, and b == true

Share this post

Link to post
Share on other sites
Ok, just found a solution, because expression (_1 + _2)(p1, p2) returns a value(string), ret<string> needs to be in front of the expression:

string s = ret<string>(_1 + _2)(p1, p2);

Why the compiler can't deduce the return type?

And why the (_1 < _2)(p1, p2) works? Is that because the return type is unknown, so int is assumed?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!