brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 5113651 Raw
62 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_trivially_assignable12 13#include <type_traits>14#include "test_macros.h"15 16template <class T, class U>17void test_is_trivially_assignable()18{19    static_assert(( std::is_trivially_assignable<T, U>::value), "");20#if TEST_STD_VER > 1421    static_assert(( std::is_trivially_assignable_v<T, U>), "");22#endif23}24 25template <class T, class U>26void test_is_not_trivially_assignable()27{28    static_assert((!std::is_trivially_assignable<T, U>::value), "");29#if TEST_STD_VER > 1430    static_assert((!std::is_trivially_assignable_v<T, U>), "");31#endif32}33 34struct A35{36};37 38struct B39{40    void operator=(A);41};42 43struct C44{45    void operator=(C&);  // not const46};47 48int main(int, char**)49{50    test_is_trivially_assignable<int&, int&> ();51    test_is_trivially_assignable<int&, int> ();52    test_is_trivially_assignable<int&, double> ();53 54    test_is_not_trivially_assignable<int, int&> ();55    test_is_not_trivially_assignable<int, int> ();56    test_is_not_trivially_assignable<B, A> ();57    test_is_not_trivially_assignable<A, B> ();58    test_is_not_trivially_assignable<C&, C&> ();59 60  return 0;61}62