79 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// type_traits10 11// template <class T, class... Args>12// struct is_trivially_constructible;13 14#include <type_traits>15#include "test_macros.h"16 17template <class T>18void test_is_trivially_constructible()19{20 static_assert(( std::is_trivially_constructible<T>::value), "");21#if TEST_STD_VER > 1422 static_assert(( std::is_trivially_constructible_v<T>), "");23#endif24}25 26template <class T, class A0>27void test_is_trivially_constructible()28{29 static_assert(( std::is_trivially_constructible<T, A0>::value), "");30#if TEST_STD_VER > 1431 static_assert(( std::is_trivially_constructible_v<T, A0>), "");32#endif33}34 35template <class T>36void test_is_not_trivially_constructible()37{38 static_assert((!std::is_trivially_constructible<T>::value), "");39#if TEST_STD_VER > 1440 static_assert((!std::is_trivially_constructible_v<T>), "");41#endif42}43 44template <class T, class A0>45void test_is_not_trivially_constructible()46{47 static_assert((!std::is_trivially_constructible<T, A0>::value), "");48#if TEST_STD_VER > 1449 static_assert((!std::is_trivially_constructible_v<T, A0>), "");50#endif51}52 53template <class T, class A0, class A1>54void test_is_not_trivially_constructible()55{56 static_assert((!std::is_trivially_constructible<T, A0, A1>::value), "");57#if TEST_STD_VER > 1458 static_assert((!std::is_trivially_constructible_v<T, A0, A1>), "");59#endif60}61 62struct A63{64 explicit A(int);65 A(int, double);66};67 68int main(int, char**)69{70 test_is_trivially_constructible<int> ();71 test_is_trivially_constructible<int, const int&> ();72 73 test_is_not_trivially_constructible<A, int> ();74 test_is_not_trivially_constructible<A, int, double> ();75 test_is_not_trivially_constructible<A> ();76 77 return 0;78}79