Boost logo

Boost Users :

Subject: Re: [Boost-users] Insertion/Use of boost::multi_index - new thread
From: Joaquin M López Muñoz (joaquinlopezmunoz_at_[hidden])
Date: 2016-09-19 05:58:56


El 19/09/2016 a las 11:29, Ram escribió:
> Hi,
>
> When I try to create a object of this,
>
> typedef boost::multi_index_container<
> ClassX*,//mapped value
> boost::multi_index::indexed_by<//list of indices
> boost::multi_index::hashed_unique<
> boost::multi_index::const_mem_fun<ParentClassOfX, Key1,
> &ParentClassOfX::getKey1>//hashed index by unique Key1
> >,
> boost::multi_index::hashed_unique<
> boost::multi_index::const_mem_fun<ParentClassOfX, Vs64,
> &ParentClassOfX::getKey2>//hashed index by unique Key1
> >
> >
> >ClassXMultiKeyIndexed;
>
> like,
> ClassXMultiKeyIndexed sample;
>
> and insert a pointer like this,
>
> ClassX *a;
> ClassXMultiKeyIndexed sample;
>
> //a is not NULL and is filled up before the below insert
> sample.insert(a);
>
> This is the compilation error, it compiles fine if "sample.insert(a)"
> is commented out.
>
> Compilation error :
>
> Compiling...
> stm_container_manager_abc.cpp
> c:\code\common\lib\boost\boost\detail\allocator_utilities.hpp(153) :
> error C2061: syntax error : identifier 'p'
> c:\code\common\lib\boost\boost\multi_index\detail\index_base.hpp(105)
> : see reference to function template instantiation 'void
> boost::detail::allocator::construct<Container*>(void *,const Type &)'
> being compiled
> with
> [
> Type=Container *
> ]
> [...]

The problem is not apparent to me from the contextual info you're
providing, what I see
seems basically correct but surely some detail is missing. A problem
with your post is
that you're providing a modified version of the real code (for instance,
where you say
ClassX your code is actually dealing with a class called Container) and
information is
probably lost in translation.

I've turned your sample code into a complete test program:

http://coliru.stacked-crooked.com/a/b63feba754f81f67

that compiles and run without problem. You might want to:

1. See if this same test program works OK in your environment.
2. Compare with your real code and try to spot a significant difference.
3. Turn your real code into a complete test program showing the error
that the rest
here at the list can check locally and investigate.

Joaquín M López Muñoz



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