|
Boost Users : |
Subject: [Boost-users] Why does gcc require explicit template arguments with my boost::bind
From: Chris Stankevitz (chrisstankevitz_at_[hidden])
Date: 2012-12-06 00:34:06
Hello,
Below I implement a function "Chain" that takes two functions and
executes them both.
The first approach succeeds: direct function call.
The second approach succeeds: call via bind with explicit template arguments
The third and fourth approaches fail: call via bind without explicit
template arguments (with/without boost::protect)
Question: Why do I have to use explicit template arguments when using
bind with Chain?
Thank you,
Chris
===
#include <boost/bind.hpp>
#include <boost/function.hpp>
template <typename TAFunc1, typename TAFunc2>
void Chain(const TAFunc1& Func1, TAFunc2& Func2)
{
Func1();
Func2();
}
void f()
{
}
void foo()
{
boost::function<void()> x = boost::bind(f);
boost::function<void()> y = boost::bind(f);
Chain(x, y);
boost::bind(Chain<boost::function<void()>, boost::function<void()> >, x, y)();
boost::bind(Chain, x, y)();
boost::bind(Chain, boost::protect(x), boost::protect(y))();
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net