• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
main()15 int main()
16 {
17     {
18     std::unique_ptr<int> p1 = std::make_unique<int>(1);
19     assert ( *p1 == 1 );
20     p1 = std::make_unique<int> ();
21     assert ( *p1 == 0 );
22     }
23 
24     {
25     std::unique_ptr<std::string> p2 = std::make_unique<std::string> ( "Meow!" );
26     assert ( *p2 == "Meow!" );
27     p2 = std::make_unique<std::string> ();
28     assert ( *p2 == "" );
29     p2 = std::make_unique<std::string> ( 6, 'z' );
30     assert ( *p2 == "zzzzzz" );
31     }
32 }
33