Opened 8 years ago

#4542 new Bugs

bind() should use boost::result_of

Reported by: anonymous Owned by: Peter Dimov
Milestone: Boost 1.44.0 Component: bind
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc:


if at all possible boost::bind(F(),...) should use boost::result_of<F(...)> instead of directly accessing F::result_type.

this way functors whose result type depends on the argument types could be used in bind(), for example:

#include <boost/bind.hpp>
#include <boost/utility/result_of.hpp>

using namespace boost;

struct F{
  template<typename Args>
  struct result;
  template<typename T>
  T operator()(T const &t) const{ return t; }

template<typename T>
struct F::result<F(T const &)>{
  typedef T type;

template<typename F>
void g(F const &f){
  typename boost::result_of<F()>::type res=f();

int main(){
  f(bind(F(),4)); //error. no result_type in F

Attachments (1)

bind.patch (9.0 KB) - added by anonymous 8 years ago.
PoC patch. only supports 2 arguments and specific bindings

Download all attachments as: .zip

Change History (1)

Changed 8 years ago by anonymous

Attachment: bind.patch added

PoC patch. only supports 2 arguments and specific bindings

Note: See TracTickets for help on using tickets.