誰かがこの問題で私を助けることができるかどうか疑問に思っていました. 過負荷であるため、VS2010 で std::make_pair を使用するといくつかの問題があることを読んでいますが、機能するいくつかの回避策を見つけましたが、ここで機能させる方法を見つけることができません自分。
コードの一部を以下に示します。
namespace tree {
#define container std::vector
typedef container<IConnType const*> node_data;
///tree node's brief
struct tree_node
{
STD_STRING name;
node_data types;
};
struct branch;
typedef container<branch> sub_tree;
///branch's brief
struct branch
{
tree_node node;
sub_tree tree;
};
}
template<typename T>
///address of's brief
struct address_of
{
T* operator()(T& x) const
{
return &x;
}
T const* operator()(T const& x) const
{
return &x;
}
};
typedef std::pair<tree::branch*,HTREEITEM> step_info;
std::vector<step_info> steps;
/// after we fill steps ///
HTREEITEM new_item = m_conntree.InsertItem(&tvi); // m_conntree is a CTreeCtrl; tvi is a TVINSERTSTRUCT
std::transform(step.first->tree.begin()
, step.first->tree.end()
, std::back_inserter(steps)
, boost::bind(&std::make_pair<tree::branch*,HTREEITEM>
, boost::bind<tree::branch*>(address_of<tree::branch>()
, _1
)
, new_item
)
);
問題はここにあります (コードの残りの部分はアイデアを提供するためのものです):
std::transform(step.first->tree.begin()
, step.first->tree.end()
, std::back_inserter(steps)
, boost::bind(&std::make_pair<tree::branch*,HTREEITEM>
, boost::bind<tree::branch*>(address_of<tree::branch>()
, _1
)
, new_item
)
);
(他のスレッドで読んだように)キャストを試みましたが、うまくいきませんでした...これは私が試したものです:
typedef std::pair<tree::branch*,HTREEITEM> (*MakePairType)(tree::branch*,HTREEITEM);
std::transform(step.first->tree.begin()
, step.first->tree.end()
, std::back_inserter(steps)
, boost::bind((MakePairType)&std::make_pair<tree::branch*,HTREEITEM>
, boost::bind<tree::branch*>(address_of<tree::branch>()
, _1
)
, new_item
)
);
誰かがこれで私を助けてくれることを願っています...私はこのプロジェクトをコンパイルしようとして長い間立ち往生しています...
ちなみに、boost::bind (100 以上) で多くのエラーがスローされます...そしてboost::bind を取り出すと、std::make_pair のどのオーバーロードが分からないというエラーが表示されます使用する、
よろしくお願いします!