1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// UNSUPPORTED: c++98, c++03, c++11
11#include <memory>
12#include <string>
13#include <cassert>
14
15//    The only way to create an unique_ptr<T[]> is to default construct them.
16
17class foo {
18public:
19    foo () : val_(3) {}
20    int get () const { return val_; }
21private:
22    int val_;
23    };
24
25int main()
26{
27    {
28    auto p1 = std::make_unique<int[]>(5);
29    for ( int i = 0; i < 5; ++i )
30        assert ( p1[i] == 0 );
31    }
32
33    {
34    auto p2 = std::make_unique<std::string[]>(5);
35    for ( int i = 0; i < 5; ++i )
36        assert ( p2[i].size () == 0 );
37    }
38
39    {
40    auto p3 = std::make_unique<foo[]>(7);
41    for ( int i = 0; i < 7; ++i )
42        assert ( p3[i].get () == 3 );
43    }
44}
45