make_unique.single.pass.cpp revision fd7481e96de307dd0e43c96d5b025b7c779f72d7
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#include <memory>
11#include <string>
12#include <cassert>
13
14int main()
15{
16#if _LIBCPP_STD_VER > 11
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#endif  // _LIBCPP_STD_VER > 11
33}
34