brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · be1f016 Raw
64 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_nothrow_assignable12 13#include <type_traits>14#include "test_macros.h"15 16template <class T, class U>17void test_is_nothrow_assignable()18{19    static_assert(( std::is_nothrow_assignable<T, U>::value), "");20#if TEST_STD_VER > 1421    static_assert(( std::is_nothrow_assignable_v<T, U>), "");22#endif23}24 25template <class T, class U>26void test_is_not_nothrow_assignable()27{28    static_assert((!std::is_nothrow_assignable<T, U>::value), "");29#if TEST_STD_VER > 1430    static_assert((!std::is_nothrow_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_nothrow_assignable<int&, int&> ();51    test_is_nothrow_assignable<int&, int> ();52#if TEST_STD_VER >= 1153    test_is_nothrow_assignable<int&, double> ();54#endif55 56    test_is_not_nothrow_assignable<int, int&> ();57    test_is_not_nothrow_assignable<int, int> ();58    test_is_not_nothrow_assignable<B, A> ();59    test_is_not_nothrow_assignable<A, B> ();60    test_is_not_nothrow_assignable<C, C&> ();61 62  return 0;63}64