Opened 5 years ago

Closed 5 years ago

#13307 closed Bugs (fixed)

multi_index_container can't work with _com_ptr_t

Reported by: andrewaa59@… Owned by: Joaquín M López Muñoz
Milestone: To Be Determined Component: multi_index
Version: Boost 1.60.0 Severity: Problem
Keywords: c++ Visual Studio _com_ptr_t Cc:

Description

I try to use multi_index_container with _com_ptr_t objects. I can compile code with no errors, but program crashes in runtime.

Standard containers (std::map, std::set, std::vector) work perfectly with _com_ptr_t.

The sample code:

#include "stdafx.h"
#include <boost\multi_index_container.hpp>
#include <boost\multi_index\random_access_index.hpp>
#include <boost\multi_index\global_fun.hpp>
#include <boost\multi_index\ordered_index.hpp>

#import "C:\Windows\SysWOW64\msxml6.dll" exclude("ISequentialStream", "_FILETIME")

using CTest = 
  boost::multi_index_container<MSXML2::IXMLDOMDocument2Ptr, 
      boost::multi_index::indexed_by<boost::multi_index::random_access<>>>;


int main()
{
	::CoInitialize(nullptr);

	CTest tst;

	MSXML2::IXMLDOMDocumentPtr doc;
	doc.CreateInstance(CLSID_DOMDocument);

	**tst.push_back(std::move(doc));** <-- crash here

	::CoUninitialize();

  return 0;
}

Change History (7)

comment:1 by andrewaa59gmail.com, 5 years ago

Component: Nonemulti_index
Owner: set to Joaquín M López Muñoz

comment:2 by Andrey Alifanov <andrewaa59gmail.com>, 5 years ago

Keywords: c++ Visual Studio _com_ptr_t added

comment:3 by Joaquín M López Muñoz, 5 years ago

Hi Andrey

I think the issue is solved by these two commits:

Would you mind patching your local installation of Boost with these and checking whether things work now? The only part where things will still go wrong with overloaded operator& is serialization, but seems the author is working on this in parallel.

Thank you,

comment:4 by anonymous, 5 years ago

Hi Joaquin

I'll try it as soon as possible and report about results. Thank you very much for amazingly quick fix.

comment:5 by andrewaa59@…, 5 years ago

Hi Joaquin.

Anonym - it was me. Very strange UI here.

I've tried your fix on my sample code - it seems to be working. At Monday I'll try it on real big code.

comment:6 by andrewaa59@…, 5 years ago

Hi Joaquin.

I've tried fix in real code - it's working. Thank you very much.

comment:7 by Joaquín M López Muñoz, 5 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.