On Wed, Dec 10, 2008 at 2:37 PM, Frank Mori Hess <frank.hess@nist.gov> wrote:

Thanks for that Frank - that just shows the perils of not posting the exact code
which is causing problems!

I have fabricated a much shorter example which exhibits the same issue for me...

#include <cstddef>
#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
#include "boost/function.hpp"

template < typename T >
  bool is_zero( const T & t )
{
  return t == 0;
}

template < typename T, std :: size_t sz >
  bool first_element_equal_zero( const T ( & array )[ sz ] )
{
  using namespace boost;
  using lambda :: bind;
  using lambda :: _1;
  using lambda :: constant_ref;

  function< const T &( unsigned ) > element = constant_ref( array )[ _1 ];
  function< bool( unsigned ) > e = bind( is_zero< T >, element( _1 ) );

  return e( 0 );
}

int main( )
{
  int a[ 10 ];

  first_element_equal_zero( a );
}

$ g++ -c element.cpp
element.cpp: In function `bool first_element_equal_zero(const T (&)[sz]) [with T = int, unsigned int sz = 10u]':
element.cpp:30:   instantiated from here
element.cpp:21: error: no match for call to `(boost::function<const int&()(unsigned int)>) (const boost::lambda::lambda_
functor<boost::lambda::placeholder<1> >&)'
/usr/include/boost/function/function_template.hpp:810: note: candidates are: typename boost::function1<R, T0>::result_ty
pe boost::function1<R, T0>::operator()(T0) const [with R = const int&, T0 = unsigned int]

Which still evades my comprehension! I'd appreciate some guidance here.

Thanks.

- Rob.