1//
2// A negative test for unique_ptr dynamic_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
11#include <boost/pointer_cast.hpp>
12#include <memory>
13
14struct B
15{
16 virtual ~B()
17 {
18 }
19};
20
21struct D: B
22{
23};
24
25int main()
26{
27 std::unique_ptr<D[]> p1( new D[ 1 ] );
28 std::unique_ptr<B[]> p2 = boost::dynamic_pointer_cast<B[]>( r: std::move( p1 ) );
29}
30

source code of boost/libs/smart_ptr/test/pointer_cast_dy_fail3.cpp