1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++03, c++11 10 #include <memory> 11 #include <string> 12 #include <cassert> 13 14 #include "test_macros.h" 15 main(int,char **)16int main(int, char**) 17 { 18 { 19 std::unique_ptr<int> p1 = std::make_unique<int>(1); 20 assert ( *p1 == 1 ); 21 p1 = std::make_unique<int> (); 22 assert ( *p1 == 0 ); 23 } 24 25 { 26 std::unique_ptr<std::string> p2 = std::make_unique<std::string> ( "Meow!" ); 27 assert ( *p2 == "Meow!" ); 28 p2 = std::make_unique<std::string> (); 29 assert ( *p2 == "" ); 30 p2 = std::make_unique<std::string> ( 6, 'z' ); 31 assert ( *p2 == "zzzzzz" ); 32 } 33 34 return 0; 35 } 36