2009/3/17 Sandeep Gupta <gupta.sandeep@gmail.com>
 Both the statements below  bind function buildPair.  While the  first
works the other fails. What could be a  possible fix. Thanks in

//---- Function to be used by bind -------------------------
template<typename X, typename Y>
std::pair<X, Y> buildPair(X x, Y y)
 std::pair<X,Y> apair(x,y);
 return apair;

(std::cout<<buildPair(_1,_2).first<<' ')(1,2);     ///--compiles fine---------

This one does not bind buildPair, it evaluates buildPair immediately. This line of code is equivalent to
  (std::cout<<_1<<' ')(1,2);

(bind(buildPair,_1,_2))(3,5);                  ///-fails------------

You should specify template arguments for buildPair.
  (bind(buildPair<int, int>,_1,_2))(3,5);

Roman Perepelitsa.