|
Boost : |
From: Howard Hinnant (hinnant_at_[hidden])
Date: 2005-05-26 08:02:55
On May 26, 2005, at 1:32 AM, Jonathan Turkanis wrote:
> Hi,
>
> The following program produces a compiler error on CodeWarrior 9.4
> (see error
> messages at end):
>
> #include <boost/noncopyable.hpp>
> #include <boost/type_traits.hpp>
>
> int main()
> {
> bool b = boost::is_pointer<boost::noncopyable>::value;
> }
>
> If I change this to:
>
> #include <boost/noncopyable.hpp>
> #include <msl_utility>
>
> int main()
> {
> bool b = Metrowerks::is_pointer<boost::noncopyable>::value;
> }
>
> everything is fine.
>
> What's up?
>
> Jonathan
>
> ---------------------------
>
> Error : illegal access from 'boost::noncopyable_::noncopyable' to
> protected/private member
> 'boost::noncopyable_::noncopyable::noncopyable(const
> boost::noncopyable_::noncopyable &)'
> (point of instantiation: 'main()')
> (instantiating:
> 'boost::is_pointer<boost::noncopyable_::noncopyable>')
> (instantiating:
> 'boost::detail::is_pointer_impl<boost::noncopyable_::noncopyable>')
> (instantiating:
> 'boost::is_member_pointer<boost::noncopyable_::noncopyable>')
> (instantiating:
> 'boost::is_member_function_pointer<boost::noncopyable_::noncopyable>')
> (instantiating:
> 'boost::detail::is_member_function_pointer_impl<boost::noncopyable_::
> noncopyable
>> ')
> (instantiating:
> 'boost::detail::is_mem_fun_pointer_select<false>::result_<boost::
> noncopyable_::n
> oncopyable>')
> is_member_function_pointer.hpp line 70 ));
I haven't dug into boost::is_pointer, but I'm guessing it involves a
tentative binding to an ellipsis:
template <class U> static two test(...);
5.2.2p7 says that binding a non-POD class type to an ellipsis has
undefined behavior. CodeWarrior's behavior in this context is to try
to pass the type by value by using the type's copy constructor, which
in this case is private, and thus triggers the access error.
Metrowerks::is_pointer has a much simpler implementation.
-Howard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk