1c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//===----------------------------------------------------------------------===//
2c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//
3c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//                     The LLVM Compiler Infrastructure
4c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//
5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open
6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details.
7c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//
8c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//===----------------------------------------------------------------------===//
9c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
10c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// type_traits
11c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
12c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// template <class T, class... Args>
13c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//   struct is_nothrow_constructible;
14c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
15c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant#include <type_traits>
16c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
17933afa9761c1c1f916161278a99284d50a594939Marshall Clowtemplate <class T>
18933afa9761c1c1f916161278a99284d50a594939Marshall Clowvoid test_is_nothrow_constructible()
19933afa9761c1c1f916161278a99284d50a594939Marshall Clow{
20933afa9761c1c1f916161278a99284d50a594939Marshall Clow    static_assert(( std::is_nothrow_constructible<T>::value), "");
21933afa9761c1c1f916161278a99284d50a594939Marshall Clow}
22933afa9761c1c1f916161278a99284d50a594939Marshall Clow
23933afa9761c1c1f916161278a99284d50a594939Marshall Clowtemplate <class T, class A0>
24933afa9761c1c1f916161278a99284d50a594939Marshall Clowvoid test_is_nothrow_constructible()
25933afa9761c1c1f916161278a99284d50a594939Marshall Clow{
26933afa9761c1c1f916161278a99284d50a594939Marshall Clow    static_assert(( std::is_nothrow_constructible<T, A0>::value), "");
27933afa9761c1c1f916161278a99284d50a594939Marshall Clow}
28933afa9761c1c1f916161278a99284d50a594939Marshall Clow
29933afa9761c1c1f916161278a99284d50a594939Marshall Clowtemplate <class T>
30933afa9761c1c1f916161278a99284d50a594939Marshall Clowvoid test_is_not_nothrow_constructible()
31933afa9761c1c1f916161278a99284d50a594939Marshall Clow{
32933afa9761c1c1f916161278a99284d50a594939Marshall Clow    static_assert((!std::is_nothrow_constructible<T>::value), "");
33933afa9761c1c1f916161278a99284d50a594939Marshall Clow}
34933afa9761c1c1f916161278a99284d50a594939Marshall Clow
35933afa9761c1c1f916161278a99284d50a594939Marshall Clowtemplate <class T, class A0>
36933afa9761c1c1f916161278a99284d50a594939Marshall Clowvoid test_is_not_nothrow_constructible()
37933afa9761c1c1f916161278a99284d50a594939Marshall Clow{
38933afa9761c1c1f916161278a99284d50a594939Marshall Clow    static_assert((!std::is_nothrow_constructible<T, A0>::value), "");
39933afa9761c1c1f916161278a99284d50a594939Marshall Clow}
40933afa9761c1c1f916161278a99284d50a594939Marshall Clow
41933afa9761c1c1f916161278a99284d50a594939Marshall Clowtemplate <class T, class A0, class A1>
42933afa9761c1c1f916161278a99284d50a594939Marshall Clowvoid test_is_not_nothrow_constructible()
43933afa9761c1c1f916161278a99284d50a594939Marshall Clow{
44933afa9761c1c1f916161278a99284d50a594939Marshall Clow    static_assert((!std::is_nothrow_constructible<T, A0, A1>::value), "");
45933afa9761c1c1f916161278a99284d50a594939Marshall Clow}
46933afa9761c1c1f916161278a99284d50a594939Marshall Clow
47c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantclass Empty
48c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant{
49c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant};
50c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
51c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantclass NotEmpty
52c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant{
53c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    virtual ~NotEmpty();
54c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant};
55c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
56c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantunion Union {};
57c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
58c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantstruct bit_zero
59c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant{
60c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    int :  0;
61c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant};
62c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
63c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantclass Abstract
64c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant{
65c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    virtual ~Abstract() = 0;
66c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant};
67c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
68c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantstruct A
69c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant{
70c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    A(const A&);
71c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant};
72c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
73c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantint main()
74c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant{
75933afa9761c1c1f916161278a99284d50a594939Marshall Clow    test_is_nothrow_constructible<int> ();
76933afa9761c1c1f916161278a99284d50a594939Marshall Clow    test_is_nothrow_constructible<int, const int&> ();
77933afa9761c1c1f916161278a99284d50a594939Marshall Clow    test_is_nothrow_constructible<Empty> ();
78933afa9761c1c1f916161278a99284d50a594939Marshall Clow    test_is_nothrow_constructible<Empty, const Empty&> ();
79933afa9761c1c1f916161278a99284d50a594939Marshall Clow
80933afa9761c1c1f916161278a99284d50a594939Marshall Clow    test_is_not_nothrow_constructible<A, int> ();
81933afa9761c1c1f916161278a99284d50a594939Marshall Clow    test_is_not_nothrow_constructible<A, int, double> ();
82933afa9761c1c1f916161278a99284d50a594939Marshall Clow    test_is_not_nothrow_constructible<A> ();
83c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant}
84