Boost.MultiIndex模板替换失败

Boost.MultiIndex template substitution failure?

本文关键字:替换 失败 MultiIndex Boost      更新时间:2023-10-16

我正在尝试使用boost::multi_index_container,它似乎在某个地方被模板元编程的魔力所窒息。我得到了一个巨大的错误转储,以结尾

/opt/local/include/boost/multi_index/hashed_index.hpp:743:9:错误:'类boost::multi_index::detail::hashed_index,boost::hash,std::equal_to,boost::multi_index::detail::nth_layer<1.boost::intrusive_ptr,boost::multi_index::indexed_by>,boost::multi_index::ordered_non_unique,&md::Order::px>>,std::分配器>>,boost::mpl::vector0,boost::multi_index::detail::hashed_unique_tag>'没有名为的成员'final_delete_node_'这个->final_delete_node_(

我在Mac OS X.8 Mountain Lion上使用Boost 1.53(Mac端口)。如何编译以下代码?谢谢

#include <boost/multi_index_container.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/mem_fun.hpp>
#include "Product.hpp"
#include <iostream>
int main(int argc, char* argv[])
{
    boost::multi_index_container<
        boost::intrusive_ptr<Product>,
        boost::multi_index::indexed_by<
            boost::multi_index::hashed_unique<
                boost::multi_index::const_mem_fun<
                    Product,
                    id_t,
                    static_cast<id_t (Product::*)() const>(&Product::id)
                >
            >,
            boost::multi_index::ordered_non_unique<
                boost::multi_index::const_mem_fun<
                    Product,
                    price_t,
                    static_cast<price_t (Product::*)() const>(&Product::price)
                >
            >
        >
    > cont;
    auto o = boost::intrusive_ptr<Product>(new Product());
    o->id(1).price(price_t(14.75));
    cont.insert(o);
    auto it = cont.get<1>().find(price_t(14.75));
    if (it!=cont.get<1>().end())
        std::cout << *(it);
    return 0;
}

未能包含<boost/multi_index/ordered_índex.hpp>