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;

  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


  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()

         / \
temp -> + f3
       / \
      f1 f2

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

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?



 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:

Boost list run by bdawes at, gregod at, cpdaniel at, john at