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
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
, boost::multi_index::const_mem_fun , 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
(which is what you've written), the definition has to follow this structure:
indexed_by< hashed_unique
, hashed_unique 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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users