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 #include <assert.h> 10 #include <memory> 11 #include <new> 12 13 #include "test_macros.h" 14 15 typedef std::__compressed_pair<int, unsigned> IntPair; 16 test_constructor()17void test_constructor() { 18 IntPair value; 19 assert(value.first() == 0); 20 assert(value.second() == 0); 21 22 value.first() = 1; 23 value.second() = 2; 24 new (&value) IntPair; 25 assert(value.first() == 0); 26 assert(value.second() == 0); 27 } 28 test_constructor_default_init()29void test_constructor_default_init() { 30 IntPair value; 31 value.first() = 1; 32 value.second() = 2; 33 34 new (&value) IntPair(std::__default_init_tag(), 3); 35 assert(value.first() == 1); 36 assert(value.second() == 3); 37 38 new (&value) IntPair(4, std::__default_init_tag()); 39 assert(value.first() == 4); 40 assert(value.second() == 3); 41 42 new (&value) IntPair(std::__default_init_tag(), std::__default_init_tag()); 43 assert(value.first() == 4); 44 assert(value.second() == 3); 45 } 46 main(int,char **)47int main(int, char**) 48 { 49 test_constructor(); 50 test_constructor_default_init(); 51 return 0; 52 } 53