473,898 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

boost.lambda problem

Compiling with g++ 4:

This line:
if_then_else_re turn(_1 == 0, 64, _1)

When called with a bignum class as an argument yields:

/usr/include/boost/lambda/if.hpp: In member function 'RET
boost::lambda:: lambda_
functor_base<bo ost::lambda::ot her_action<boos t::lambda::ifth enelsereturn_ac tion>
, Args>::call(A&, B&, C&, Env&) const [with RET = const bignum&, A =
const bignu
m, B = const boost::tuples:: null_type, C = const
boost::tuples:: null_type, Env =
const boost::tuples:: null_type, Args =
boost::tuples:: tuple<boost::la mbda::lamb
da_functor<boos t::lambda::lamb da_functor_base <boost::lambda: :relational_act ion<b
oost::lambda::e qual_action>,
boost::tuples:: tuple<boost::la mbda::lambda_fu nctor<
boost::lambda:: placeholder<1, const int, boost::tuples:: null_type,
boost::tup
les::null_type, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuple
s::null_type, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples:
:null_type >, const int,
boost::lambda:: lambda_functor< boost::lambda:: placeho
lder<1, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples:: nu
ll_type, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples:: null
_type, boost::tuples:: null_type>]':
/usr/include/boost/lambda/detail/lambda_functors .hpp:148:
instantiated from 't
ypename T::sig<boost::t uples::tuple<A& , boost::tuples:: null_type,
boost::tuples:
:null_type, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples:: n
ull_type, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples:: nul
l_type, boost::tuples:: null_type::type
boost::lambda:: lambda_functor< Base>::o
perator()(A&) const [with A = const bignum, T =
boost::lambda:: lambda_functor_ ba
se<boost::lambd a::other_action <boost::lambda: :ifthenelseretu rn_action>,
boost::t
uples::tuple<bo ost::lambda::la mbda_functor<bo ost::lambda::la mbda_functor_ba se<bo
ost::lambda::re lational_action <boost::lambda: :equal_action>,
boost::tuples:: tupl
e<boost::lambda ::lambda_functo r<boost::lambda ::placeholder<1 , const
int, boos
t::tuples::null _type, boost::tuples:: null_type,
boost::tuples:: null_type, boost:
:tuples::null_t ype, boost::tuples:: null_type,
boost::tuples:: null_type, boost::t
uples::null_typ e, boost::tuples:: null_type >, const int,
boost::lambda:: lambd
a_functor<boost ::lambda::place holder<1, boost::tuples:: null_type,
boost::tupl
es::null_type, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples
::null_type, boost::tuples:: null_type, boost::tuples:: null_type]'
.../pp_datatypes.h: 454: instantiated from 'std::string
pp_transform_da tatype<Td
efunc, Tenfunc>::evalu ate(const pp_value&) const [with Tdefunc =
boost::lambda::
lambda_functor< boost::lambda:: lambda_functor_ base<boost::lam bda::other_acti on<bo
ost::lambda::if thenelsereturn_ action>,
boost::tuples:: tuple<boost::la mbda::lambd
a_functor<boost ::lambda::lambd a_functor_base< boost::lambda:: relational_acti on<bo
ost::lambda::eq ual_action>,
boost::tuples:: tuple<boost::la mbda::lambda_fu nctor<b
oost::lambda::p laceholder<1, const int, boost::tuples:: null_type,
boost::tupl
es::null_type, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples
::null_type, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples::
null_type >, const int,
boost::lambda:: lambda_functor< boost::lambda:: placehol
der<1, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples:: nul
l_type, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples:: null_
type, boost::tuples:: null_type >, Tenfunc =
boost::lambda:: lambda_functor< boo
st::lambda::lam bda_functor_bas e<boost::lambda ::arithmetic_ac tion<boost::lam bda::
minus_action>,
boost::tuples:: tuple<boost::la mbda::lambda_fu nctor<boost::la mbda:
:placeholder<1, const int, boost::tuples:: null_type,
boost::tuples:: null_type
, boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples:: null_type,
boost::tuples:: null_type, boost::tuples:: null_type,
boost::tuples:: null_type
>]'
cpuid/generic_device. cpp:419: instantiated from here
/usr/include/boost/lambda/if.hpp:315: warning: returning reference to
temporary
make[2]: *** [cpuid/generic_device. o] Error 1
make[1]: *** [devices] Error 2
make: *** [devices/all_devices.o] Error 2
cpuid/generic_device. cpp:419 is the last line of the file before the
final function's closing curly.

Changing the second _1 to an integer literal works.

I'm pretty much out of template-fu at this point...

Help?
Aug 1 '08 #1
1 2635

"Tim H" <th*****@gmail. comwrote in message
news:f5******** *************** ***********@h17 g2000prg.google groups.com...
cpuid/generic_device. cpp:419: instantiated from here
/usr/include/boost/lambda/if.hpp:315: warning: returning reference to
temporary
make[2]: *** [cpuid/generic_device. o] Error 1
make[1]: *** [devices] Error 2
make: *** [devices/all_devices.o] Error 2
cpuid/generic_device. cpp:419 is the last line of the file before the
final function's closing curly.

Changing the second _1 to an integer literal works.

I'm pretty much out of template-fu at this point...

Help?
You would get much better help on boost.org, but heres my 2.p's worth

Anyway the warning is pretty serious and shouldnt be ignored if you are
creating a temporary in some lambda function.
Maybe Investigate how the bignum semantics differs from the inbuilt int in
terms of copying and so on. Of course if its your own bignum then look at
premature optimisation. Are you returning by const cref as a hopeful
optimisation when you should be returning by value (e.g copying your
bignum)?

The other thing to try is (IIRC) to use one of the lambda mungwrappers to
try to enforce constness of your _1 arg.

IMO lambda's coolness factor is way higher than its usefulness ... ;-)

regards
Andy Little

Aug 1 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

205
10780
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
3
2135
by: Rafal Dabrowa | last post by:
Suppose I have the following structure: struct xy { int x, y; }; and the following vector: vector<xy> v(10); I want to use boost/lambda for find an item in the table. Let's say, with x member value equal to 10. I wrote
6
4049
by: Toby Bradshaw | last post by:
Hi, Consider the following: class A { public: virtual bool foo() = 0; };
1
2712
by: flopbucket | last post by:
Hi, After reading a bit about boost::lambda, I became curious how they implemented it. I downloaded it and had a look, but the all the headers and multiple templates make it a bit difficult to follow in a short time (I only spent maybe 15 minutes). Anyway, I decided to try some ideas out and came up with the following basic example: (obviously this is very far from boost::lambda and is special for streams, etc., but just trying to...
4
2496
by: silverburgh.meryl | last post by:
I have code which uses Boost lambda in a template like this: using namespace boost::lambda; template<class T> bool lessThanXY( T& src, T& dest ) { return (src.getY() < dest.getY()); } template<class T1, class T2>
3
3806
by: rammel | last post by:
hi, can't I call member functions from an placeholder of a boost-like lambda expression? look on the example below please: ----------------------------------------------------------- #include <iostream> #include <algorithm> #include <iterator>
0
1774
by: Barry Ding | last post by:
#include <map> #include <utility> #include <algorithm> #include <iostream> #include <list> #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> using namespace std;
1
2260
by: nandor.sieben | last post by:
Let m be of type vector<vector<int. I am trying to sort each element of m: for_each(m.begin(), m.end(), bind(sort, *_1.begin(), *_1.end()); This does not work: 'const struct boost::lambda::lambda_functor<boost::lambda::placeholder<1' has no member named 'begin'
3
2226
by: Stuart Golodetz | last post by:
Hi, Just wondering why the following code doesn't work: #include <iostream> #include <boost/lambda/lambda.hpp> using namespace boost::lambda; int main()
0
9993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
11254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10854
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10946
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5876
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4295
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3303
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.