Boost logo

Boost :

Subject: Re: [boost] [1.39.0][Signals2] Release branch test failures
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-04-13 15:08:58

Hash: SHA1

On Monday 13 April 2009, Peter Dimov wrote:
> I haven't. What seems to be happening is that when you pass _1, which is
> inline arg<1> _1() { .. }
> to A1 const& a1, A1 is properly deduced as a function type, but the const
> is not dropped, as it should be; instead, the type of a1 becomes arg<1>
> (&)() const (which is illegal BTW). When this a1 is passed (by value) to
> boost::bind, it decays to its corresponding pointer type, arg<1> (*)()
> const - which is also illegal. :-)
> A workaround is to use pass by value instead of A1 const&.

Yes, that seems to fix it. If it is at all helpful, I've attached a more
minimal test program that triggers the bug with g++ 4.0.1 (compiles fine with
g++ 4.3.2). Changing the placeholder to be passed by value makes the compile
error go away.
Version: GnuPG v1.4.9 (GNU/Linux)


Content-Type: text/x-c++src;
  charset="iso 8859-15";
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;

// Copyright (C) Frank Mori Hess 2009

// Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at

#include <boost/bind.hpp>
#include <boost/function.hpp>

template<typename F, typename A1>
        void binder_template(const F &func,
                const A1 &arg1
// forwarding arg1 by value instead of as a const reference fixes compile error on gcc 4.0.1
// A1 arg1
        boost::function1<int, int> x = boost::bind(func, arg1);

int f(int x)
        return x;

int main()
        binder_template(&f, _1);

  return 0;


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