【C++】Boost使い集まれ!

このエントリーをはてなブックマークに追加
以下のソースをコンパイルするとエラーが出るのは何故なんでしょうか。
コメントアウトした部分のようにすれば大丈夫なんですが。

ソース:
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <iostream>
using namespace std;

int func1(int n)
{
return n;
}

int func2(int n1, int n2)
{
return n1+n2;
}

class Test
{
public:
template <class T>
Test(T fn)
{
cout << fn(1) << endl;
}
};
863862:03/07/28 02:57
続き。

int main()
{
Test t1(boost::function<int (int)>(boost::bind(func1, _1)));
Test t2(boost::function<int (int)>(boost::bind(func2, 10, _1)));
//boost::function<int (int)> f1(boost::bind(func1, _1));
//boost::function<int (int)> f2(boost::bind(func2, 10, _1));
//Test t1(f1);
//Test t2(f2);

return 0;
}

エラーメッセージ:
>g++ t107.cpp
t107.cpp: In function `int main()':
t107.cpp:29: redefinition of `boost::function<int ()(int), std::allocator<void>
> boost::bind'
t107.cpp:28: `boost::function<int ()(int), std::allocator<void> > boost::bind'
previously declared here
t107.cpp:29: declaration of `boost::function<int ()(int), std::allocator<void>
> boost::bind'
t107.cpp:28: conflicts with previous declaration `boost::function<int ()(int),
std::allocator<void> > boost::bind'
864862:03/07/28 02:58
補足。
コンパイラは g++ (GCC) 3.2.3 (mingw special 20030504-1) です。
865デフォルトの名無しさん:03/07/28 03:51
int bind(int);
class function
{
public:
  function(int);
};
class Test
{
public:
  Test(function);
};
int main()
{
  Test t1(function(bind(0)));
  Test t2(function(bind(1)));
  return 0;
}

: In function `int main()':
:15: redeclaration of `function bind'
:14: `function bind' previously declared here
:15: declaration of `function bind'
:14: conflicts with previous declaration `function bind'

とりあえず、問題を局所化してみた。
boostもtemplateも関係ないらしい。
gccのバグかな。
866865:03/07/28 03:58
おもしろそうだから勝手にageさせてもらった。
ちなみに、
Test t1((function(bind(0))));
Test t2((function(bind(1))));
こうすれば、宣言と式の曖昧さが解決されて、
意図しているであろう本来の意味が、gccに伝わる。
関数宣言と思われるからでは?
バグではなく、規格通りかと。
868865:03/07/29 00:42
>>867
エラーメッセージをよく見てみな。