Boost.Function and template function
Dear all,
I get a crash when I try to wrap a template function with Boost.Function. I
use VStudio 2003 sp1. But maybe the used syntax is wrong:
#include
Since no one react, I tried to reverse engineer Boost.Function and pin down
the problem:
template
On Jun 26, 2007, at 5:05 PM, gast128 wrote:
Since no one react, I tried to reverse engineer Boost.Function and pin down the problem:
template
struct Functor { template <typename F> Functor(F f, int i = 0) : m_pf(0) { m_pf = reinterpret_cast<Pf>(f); } template <typename T> R Invoke(T t) { typedef R (*Pf1)(Arg1); return (*(Pf1)m_pf)(t); }
typedef void (*Pf)(void); Pf m_pf; };
template <typename T> bool func_template(T* p) { return p != 0; }
void TestBugFunctor() { Functor
fc2 = &func_template<int>; fc2.Invoke((int*)0); //crash } The trick with the extra dummy constructor argument is copied form boost function header files. Without it one gets an ICE, but with it, VStudio 2003 sp1 generates a suspectable call.
Oh, that's bad. I don't have this compiler on hand to work with... if someone has a workaround, I would gladly apply it to Boost.Function. - Doug
participants (2)
-
Doug Gregor
-
gast128