Boost logo

Boost Users :

Subject: Re: [Boost-users] Insertion/Use of boost::multi_index
From: Ram (sourceopen_at_[hidden])
Date: 2016-09-19 03:32:13


Hi Joaquin,

This is the exact error I am facing,

When I insert like "sample.insert(&a);", I get errors like,

.
.
.
kytj.cpp
ky_op_tj.cpp
c:\code\common\lib\boost\boost\multi_index\hashed_index.hpp(1155) : error
C2064: term does not evaluate to a function taking 2 arguments
        class does not define an 'operator()' or a user defined conversion
operator to a pointer-to-function or reference-to-function that takes
appropriate number of arguments
        c:\code\common\lib\\boost\boost\multi_index\hashed_index.hpp(1152)
: while compiling class template member function 'bool
boost::multi_index::detail::hashed_index<KeyFromValue,
Hash,Pred,SuperMeta,TagList,Category>::link_point(Container *const
,boost::multi_index::detail::hashed_index_base_node_impl<Allocator>
*&,boost::multi_index::detail::hashed_unique_tag)'
        with
        [
            KeyFromValue=boost::multi_index::const_mem_fun<DBObject,
Key1,DBObject::getKey1>,
            Hash=boost::multi_index::const_mem_fun<DBObject,Vs64,
DBObject::getKey2>,
            Pred=boost::multi_index::const_mem_fun<DBObject,
VString,DBObject::getEntityName>,
            SuperMeta=boost::multi_index::detail::nth_layer<1,Container
*,boost::multi_index::indexed_by<boost::multi_index::hashed_
unique<boost::multi_index::const_mem_fun<DBObject,Key1,
DBObject::getKey1>,boost::multi_index::const_mem_fun<
DBObject,Vs64,DBObject::getKey2>,boost::multi_index::const_mem_fun<DBObject,
VString,DBObject::getEntityName>>>,std::allocator<Container *>>,
            TagList=boost::mpl::vector0<boost::mpl::na>,
            Category=boost::multi_index::detail::hashed_unique_tag,
            Allocator=std::allocator<char>
        ]
        c:\code\common\lib\boost\boost\multi_index_container.hpp(100) : see
reference to class template instantiation 'boost::multi_index::detail::
hashed_index<KeyFromValue,Hash,Pred,SuperMeta,TagList,Category>' being
compiled
        with
        [
            KeyFromValue=boost::multi_index::const_mem_fun<DBObject,
Key1,DBObject::getKey1>,
            Hash=boost::multi_index::const_mem_fun<DBObject,Vs64,
DBObject::getKey2>,
            Pred=boost::multi_index::const_mem_fun<DBObject,
VString,DBObject::getEntityName>,
            SuperMeta=boost::multi_index::detail::nth_layer<1,Container
*,boost::multi_index::indexed_by<boost::multi_index::hashed_
unique<boost::multi_index::const_mem_fun<DBObject,Key1,
DBObject::getKey1>,boost::multi_index::const_mem_fun<
DBObject,Vs64,DBObject::getKey2>,boost::multi_index::const_mem_fun<DBObject,
VString,DBObject::getEntityName>>>,std::allocator<Container *>>,
            TagList=boost::mpl::vector0<boost::mpl::na>,
            Category=boost::multi_index::detail::hashed_unique_tag
        ]
        c:\code\common\src\biz\model\stm-stow_model\stm_container_manager_abc.h(300)
: see reference to class template instantiation 'boost::multi_index::multi_
index_container<Value,IndexSpecifierList>' being compiled
        with
        [
            Value=Container *,
            IndexSpecifierList=boost::multi_index::indexed_by<boost:
:multi_index::hashed_unique<boost::multi_index::const_mem_
fun<DBObject,Key1,DBObject::getKey1>,boost::multi_index::
const_mem_fun<DBObject,Vs64,DBObject::getKey2>,boost::
multi_index::const_mem_fun<DBObject,VString,DBObject::getEntityName>>>
        ]
xtyz.cpp
.
.
.
Build log was saved at "file://c:\code\win\Debug\obj\BuildLog.htm"
ProjABC - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Thanks,
Ram

On Mon, Sep 19, 2016 at 12:59 PM, Joaquin M López Muñoz <
joaquinlopezmunoz_at_[hidden]> wrote:

> El 19/09/2016 a las 7:54, Ram escribió:
>
> Hi All ,
>
> I have created a boost::multi_index container for my use and it compiles
> successfully.
> [...] The container I defined is ,
>
> typedef boost::multi_index_ClassX<
> ClassX*,
> boost::multi_index::indexed_by<
> boost::multi_index::hashed_unique<
> boost::multi_index::const_mem_fun<ParentOfClassX, Int64,
> &ParentOfClassX::getKey1>,
> boost::multi_index::const_mem_fun<ParentOfClassX, Int64,
> &ParentOfClassX::getKey2>,
> >
> >
> > MultiIndexedClassX;
>
>
> I'm afraid this is seriously wrong (leaving aside the translation typos
> such as
> "boost::multi_index_ClassX" instead of "boost::multi_index_container" etc.)
> The structure of a definition of a multi_index_container is
>
> multi_index_container<
> element_type,
> indexed_by<
> index_specifier1<index1 args>,
> index_specifier2<index2 args>,
> ...
> >
> >
>
> where each index_specifier is one of "hashed_unique", "hashed_non_unique",
> "ordered_unique", etc. I assume your intention is to have *two* hashed
> indices
> (by key1 and key2, respectively), so rather than
>
> indexed_by<
> hashed_unique<const_mem_fun1,const_mem_fun2>
> >
>
> (which is what you've written), the definition has to follow this
> structure:
>
> indexed_by<
> hashed_unique<const_mem_fun1>,
> hashed_unique<const_mem_fun2>
> >
>
> See the difference? Your original definition is just plain wrong, and the
> fact that it
> seems to compile is sheer luck (or lack of it): once you start trying to
> use it,
> compile-time errors will pop up. (if you're curious, Boost.MultiIndex is
> trying to use
> your second const_mem_fun as a hash function of the first const_mem_fun,
> which,
> of course, makes no sense, but this is what you instructed the lib to do).
>
> I've written a small test program reproducing your scenario that you can
> play
> with at
>
> http://coliru.stacked-crooked.com/a/456f8546e51a29e6
>
> Note that, here, sample.insert(&a) works without problems.
>
> Joaquín M López Muñoz
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net