brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 3f10907 Raw
87 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_assignable12 13#include <type_traits>14#include "test_macros.h"15 16template <class T>17void test_is_copy_assignable()18{19    static_assert(( std::is_copy_assignable<T>::value), "");20#if TEST_STD_VER > 1421    static_assert(( std::is_copy_assignable_v<T>), "");22#endif23}24 25template <class T>26void test_is_not_copy_assignable()27{28    static_assert((!std::is_copy_assignable<T>::value), "");29#if TEST_STD_VER > 1430    static_assert((!std::is_copy_assignable_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 51struct A52{53    A();54};55 56class B57{58    B& operator=(const B&);59};60 61struct C62{63    void operator=(C&);  // not const64};65 66int main(int, char**)67{68    test_is_copy_assignable<int> ();69    test_is_copy_assignable<int&> ();70    test_is_copy_assignable<A> ();71    test_is_copy_assignable<bit_zero> ();72    test_is_copy_assignable<Union> ();73    test_is_copy_assignable<NotEmpty> ();74    test_is_copy_assignable<Empty> ();75 76#if TEST_STD_VER >= 1177    test_is_not_copy_assignable<const int> ();78    test_is_not_copy_assignable<int[]> ();79    test_is_not_copy_assignable<int[3]> ();80    test_is_not_copy_assignable<B> ();81#endif82    test_is_not_copy_assignable<void> ();83    test_is_not_copy_assignable<C> ();84 85  return 0;86}87