Can someone confirm if the attached code doesn't compile intentionally
or if this is a bug? I'm sorry for not posting a minimal example but
I couldn't figure out how to reduce the problem. It requires Windows
(uses ATL::CAdapt and ATL::CComBSTR) and I've tested using VS 2005 and
VS2008. This bug manifests when the Reference type has overloaded the
address-of operator to return a type not implicitly convertible to
Value * (I believe).
Changing lines 324-326 in iterator_facade.hpp from:
static type make(Reference x)
{
return implicit_cast<type>(&x);
}
to:
static type make(Reference x)
{
return implicit_cast<type>(boost::addressof(x));
}
and adding the appropriate include makes the attached code compile.
Full error log below:
1>c:\dev\vendor\boost\1.37.0\boost\iterator\iterator_facade.hpp(326) :
error C2664: 'boost::implicit_cast' : cannot convert parameter 1 from
'BSTR *' to 'ATL::CComBSTR *'
1> Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
1> c:\dev\vendor\boost\1.37.0\boost\iterator\iterator_facade.hpp(325)
: while compiling class template member function 'ATL::CComBSTR
*boost::detail::operator_arrow_result::make(Reference)'
1> with
1> [
1> ValueType=ATL::CComBSTR,
1> Reference=ATL::CComBSTR &,
1> Pointer=ATL::CComBSTR *
1> ]
1> c:\dev\vendor\boost\1.37.0\boost\iterator\iterator_facade.hpp(641)
: see reference to class template instantiation
'boost::detail::operator_arrow_result'
being compiled
1> with
1> [
1> ValueType=ATL::CComBSTR,
1> Reference=ATL::CComBSTR &,
1> Pointer=ATL::CComBSTR *
1> ]
1> c:\dev\vendor\boost\1.37.0\boost\iterator\iterator_adaptor.hpp(271)
: see reference to class template instantiation
'boost::iterator_facade'
being compiled
1> with
1> [
1> Derived=test::atl::CAdapt_iteratorATL::CComBSTR,std::allocatorATL::CComBSTR>>>,
1> Value=ATL::CComBSTR,
1> CategoryOrTraversal=std::random_access_iterator_tag,
1> Reference=ATL::CComBSTR &,
1> Difference=__w64 int
1> ]
1> c:\dev\personal\boost\iterator_adaptor_bug\main.cpp(65) :
see reference to class template instantiation
'boost::iterator_adaptor'
being compiled
1> with
1> [
1> Derived=test::atl::CAdapt_iteratorATL::CComBSTR,std::allocatorATL::CComBSTR>>>,
1> Base=std::_Vector_iteratorATL::CComBSTR,std::allocatorATL::CComBSTR>>,
1> Value=ATL::CComBSTR,
1> Traversal=std::random_access_iterator_tag,
1> Reference=ATL::CComBSTR &
1> ]
1> c:\dev\personal\boost\iterator_adaptor_bug\main.cpp(103) :
see reference to class template instantiation
'test::atl::CAdapt_iterator<Iterator>' being compiled
1> with
1> [
1> Iterator=std::_Vector_iteratorATL::CComBSTR,std::allocatorATL::CComBSTR>>
1> ]
Thanks for any insight,
--Michael Fawcett