Boost logo

Boost :

From: jsiek_at_[hidden]
Date: 2000-03-18 23:49:08


After weeding though a bunch of smaller porting issues, I hit a
problem that seems a bit more serious.

Here's the error message:

"../ll/binder_base.hpp", line 244: warning: temporary used for initial value
          of reference to non-const (anachronism)
        select(get<1>(args), a, b, c),
        ^

Here's the context of the error (after preprocessing)

template<class Act, class Args>
class binder_base<action<2, Act>, Args>
{
  Args args;
public:

  explicit binder_base(const Args& a) : args(a) {}

  template<class RET, class A, class B, class C>
  RET call(A& a, B& b, C& c) const {
    return Act::template apply<RET>(
      select(get<1>(args), a, b, c),
      select(get<2>(args), a, b, c));
  }
};

and the error is triggered from this line

placeholder_basics.cpp:

  cout << "(free1 + free2 + free3)(i, j, k) = " << (free1 + free2 + free3)(i, j, k) << "\n\n";

So I think the problem is that when (free1 + free2 + free3) gets
evaluated, the result of the first addition returns a temporary
(an "int" in this case), which is then passed to the apply()
function.

          +
         / \
temp -> + f3
       / \
      f1 f2

The apply function takes references, resulting in the warning about
passing temporaries to references.

#define LL_BINARY_ACTION(OPER_SYMBOL, GROUP, OPER_NAME) \
template<> struct GROUP##<OPER_NAME> {\
  template<class RET, class A, class B>\
  RET static apply(A& a, B& b) { return a OPER_SYMBOL b; }\
};\
\

I think the fix is to make the parameter types for apply() dependent
on the return type of the inner expressions. I have a feeling this is
a non-trivial change, and may affect the design somewhat.
What do you think Jaakko?

Ciao,

Jeremy

----------------------------------------------------------------------
 Jeremy Siek
 Ph.D. Candidate email: jsiek_at_[hidden]
 Univ. of Notre Dame work phone: (650) 933-8724
 and cell phone: (415) 377-5814
 C++ Library & Compiler Group fax: (650) 932-0127
 SGI www: http://www.lsc.nd.edu/~jsiek/
----------------------------------------------------------------------


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk