0

だから私はこのようなboost_multi_indexである種のデータベースを作りました:

#include <boost\multi_index_container.hpp>
#include <boost\multi_index\ordered_index.hpp>
#include <boost\multi_index\member.hpp>
using namespace boost::multi_index;
using namespace std;

struct list_entry{
    int id;
    string name;
    string* data;
};

typedef multi_index_container<list_entry,
    indexed_by<
        ordered_unique< tag<int>, member<list_entry, int, &list_entry::id>>,                // unique id
        ordered_unique< tag<string>, member<list_entry, string, &list_entry::name>>,        // unique name
        ordered_non_unique< tag<string*>, member<list_entry, string*, &list_entry::data>>   // some data associated with the id/name
    >
>table;

class Database
{
    private:    
        table music, names;
        typedef table::index<int>::type list_id;
        typedef table::index<string>::type list_string;

    //some more code here
};

Visual Studio 2010 で問題なくコンパイルできます。

しかし、私は自分のプロジェクトを MinGW で Code::Blocks に切り替えたかったのですが、彼はそれに満足していないようです。これはコンパイル ログです:

.\source\db.h|19|error: template argument 3 is invalid|
.\source\db.h|15|error: template argument 2 is invalid|
.\source\db.h|15|error: template argument 1 is invalid|
.\source\db.h|14|error: template argument 2 is invalid|
.\source\db.h|13|warning: 'typedef' was ignored in this declaration [enabled by default]|
.\source\db.h|24|error: 'table' does not name a type|
.\source\db.h|25|error: 'table' does not name a type|
.\source\db.h|26|error: 'table' does not name a type|
C:\Program Files\boost_1_54_0\boost\system\error_code.hpp|222|warning: 'boost::system::posix_category' defined but not used [-Wunused-variable]|
C:\Program Files\boost_1_54_0\boost\system\error_code.hpp|223|warning: 'boost::system::errno_ecat' defined but not used [-Wunused-variable]|
C:\Program Files\boost_1_54_0\boost\system\error_code.hpp|224|warning: 'boost::system::native_ecat' defined but not used [-Wunused-variable]|
C:\Program Files\boost_1_54_0\boost\asio\error.hpp|244|warning: 'boost::asio::error::system_category' defined but not used [-Wunused-variable]|
C:\Program Files\boost_1_54_0\boost\asio\error.hpp|246|warning: 'boost::asio::error::netdb_category' defined but not used [-Wunused-variable]|
C:\Program Files\boost_1_54_0\boost\asio\error.hpp|248|warning: 'boost::asio::error::addrinfo_category' defined but not used [-Wunused-variable]|
C:\Program Files\boost_1_54_0\boost\asio\error.hpp|250|warning: 'boost::asio::error::misc_category' defined but not used [-Wunused-variable]|
C:\Program Files\boost_1_54_0\boost\asio\ssl\error.hpp|34|warning: 'boost::asio::error::ssl_category' defined but not used [-Wunused-variable]|
C:\Program Files\boost_1_54_0\boost\asio\detail\winsock_init.hpp|116|warning: 'boost::asio::detail::winsock_init_instance' defined but not used [-Wunused-variable]|
||=== Build finished: 7 errors, 10 warnings (0 minutes, 15 seconds) ===|

エラーはそれ以上具体的ではなく、関連する問題が見つからなかったため、私は完全に無知です。

ですから、誰かがここで答えてくれることを願っています。さらに情報が必要な場合は、後で編集します。

4

1 に答える 1

0

次のように BOOST_MULTI_INDEX_MEMBER を使用して、この問題を解決できました。

typedef multi_index_container<list_entry,
    indexed_by<
        ordered_unique< tag<int>, BOOST_MULTI_INDEX_MEMBER(list_entry, int, id)>,
        ordered_unique< tag<string>, BOOST_MULTI_INDEX_MEMBER(list_entry, string, name)>,
        ordered_non_unique< tag<string*>, BOOST_MULTI_INDEX_MEMBER(list_entry, string*, data)>
    >
>table;
于 2013-07-31T19:48:00.050 に答える