Joaquin,
The key extractor along with the unmanaged wrapper lets the MC++ use B.MI

Thanks
--Parag
--------------------------------------------------------------
typedef gcroot<employer *> _hdl_employer;

struct wrapGC {
    int idx;
    _hdl_employer _gc_hdl;
    wrapGC(employer *e):_gc_hdl(e) {
    }
   
};
struct get_Id {
    typedef int result_type;
    result_type operator()(const wrapGC* w_e) const {
        employer *gc_e = w_e->_gc_hdl;
        return gc_e->get_DrawingId();
    }
};
typedef multi_index_container<
  wrapGC*,
  indexed_by<
      ordered_non_unique<get_Id>
    >
  > employee_set;




On 4/7/06, Parag Gadkari <parag.gadkari@gmail.com> wrote:
Thanks Joaquin,
I will try it out, I really got frustated with Managed C++ 'cause it was not allowing me to use stl and boost containers with the managed objects. Its actually because the GC has to shuffle the objects around so its not possible to get the address of member variable and/or proc.

I guess what I have to do is write a nogc wrapper just like what you have pointed out and use pinned pointers.

Regards
Parag


On 4/7/06, Joaquín Mª López Muñoz <joaquin@tid.es> wrote:
 

Parag Gadkari ha escrito:

I am having trouble while using multi index container with the "managed c++" component. Here is the typedef that the compiler won't accept.
 
typedef 
multi_index_container<
  gcroot<interface_entity*>,

  indexed_by<
    ordered_unique<
identity<gcroot<interface_entity*> > >,
    ordered_non_unique
<member<gcroot<interface_entity*>int,&interface_entity::entity_drawingid > >,   > > entity_collection;
The real deal is with the member template which needs the address of member variable of the interface_entity class. Entity class is an abstract Managed type (specified with __gc), and it is not allowed to take the address of a non-static member of a managed type.

Does anybody know of a workaround?
 

Hello Parag,

A simple solution is to write a custom key extractor as described at:

http://tinyurl.com/l3g6u

In your particular case, the extractor would look like the following
(warning, uncompiled):

struct entity_drawingid_extractor
{
  typedef int result_type;
 
  result_type operator()(const gcroot<interface_entity*>& x)const
  {
    return x->entity_drawingid;
  }
};

Does this help? Is this the only problem you've stumbled upon when
using B.MI with Managed C++? I'm curious as reports of usage of
Boost libs in .NET C++-like languages are scarce.

Joaquín M López Muñoz
Telefóinca, Investigación y Desarrollo
 


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users





--
"Civilization is the limitless multiplication of unnecessary necessities." -- Mark Twain