brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · f64c40e Raw
97 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// is_copy_constructible12 13#include <type_traits>14#include "test_macros.h"15 16template <class T>17void test_is_copy_constructible()18{19    static_assert( std::is_copy_constructible<T>::value, "");20#if TEST_STD_VER > 1421    static_assert( std::is_copy_constructible_v<T>, "");22#endif23}24 25template <class T>26void test_is_not_copy_constructible()27{28    static_assert(!std::is_copy_constructible<T>::value, "");29#if TEST_STD_VER > 1430    static_assert(!std::is_copy_constructible_v<T>, "");31#endif32}33 34class Empty35{36};37 38class NotEmpty39{40public:41    virtual ~NotEmpty();42};43 44union Union {};45 46struct bit_zero47{48    int :  0;49};50 51class Abstract52{53public:54    virtual ~Abstract() = 0;55};56 57struct A58{59    A(const A&);60};61 62class B63{64    B(const B&);65};66 67struct C68{69    C(C&);  // not const70    void operator=(C&);  // not const71};72 73int main(int, char**)74{75    test_is_copy_constructible<A>();76    test_is_copy_constructible<int&>();77    test_is_copy_constructible<Union>();78    test_is_copy_constructible<Empty>();79    test_is_copy_constructible<int>();80    test_is_copy_constructible<double>();81    test_is_copy_constructible<int*>();82    test_is_copy_constructible<const int*>();83    test_is_copy_constructible<NotEmpty>();84    test_is_copy_constructible<bit_zero>();85 86    test_is_not_copy_constructible<char[3]>();87    test_is_not_copy_constructible<char[]>();88    test_is_not_copy_constructible<void>();89    test_is_not_copy_constructible<Abstract>();90    test_is_not_copy_constructible<C>();91#if TEST_STD_VER >= 1192    test_is_not_copy_constructible<B>();93#endif94 95  return 0;96}97