Hi,
The following minimal test case does not compile with VS2008 (using Boost
1.55)
#include
struct A
{
int T;
};
int main()
{
boost::optional<A> a;
}
The error is, edited for clarity:
boost\optional\optional.hpp(479) : error C2523: 'A::~T' : destructor tag
mismatch
boost\optional\optional.hpp(479) : while compiling class template member
function 'void
boost::optional_detail::optional_base<T>::destroy_impl(boost::optional_detail::optional_base<T>::is_not_reference_tag)'
with
[
T=A
]
boost\optional\optional.hpp(500) : see reference to class template
instantiation 'boost::optional_detail::optional_base<T>' being compiled
with
[
T=A
]
main.cpp(8) : see reference to class template instantiation
'boost::optional<T>' being compiled
with
[
T=A
]
After much head-scratching, I found out the culprit: the name of the
integer member!! The compiler confuses the name of member 'T' with the name
of the template parameter 'T' when trying to invoke its destructor...
The offending code is
void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->T::~T() ;
m_initialized = false ; }
Given that I cannot change struct A, is there a way to fix this?
Is this a compiler bug or a Boost.Optional bug?
Thanks in advance!