pointer_cast_co_fail2.cpp 443 B

123456789101112131415161718
  1. //
  2. // A negative test for unique_ptr const_cast
  3. //
  4. // Copyright 2016 Peter Dimov
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt
  9. //
  10. #include <boost/pointer_cast.hpp>
  11. #include <memory>
  12. int main()
  13. {
  14. std::unique_ptr<int[]> p1( new int[ 1 ] );
  15. std::unique_ptr<int> p2 = boost::const_pointer_cast<int>( std::move( p1 ) );
  16. }