boost.lambda problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim H

    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?
  • kwikius

    #2
    Re: boost.lambda problem


    "Tim H" <thockin@gmail. comwrote in message
    news:f56af0ef-ea40-46be-a447-14302a8ed57a@h1 7g2000prg.googl egroups.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





    Comment

    Working...