Howard Hinnant | 1468b66 | 2010-11-19 22:17:28 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // type_traits |
| 11 | |
| 12 | // is_move_assignable |
| 13 | |
| 14 | #include <type_traits> |
| 15 | |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 16 | template <class T> |
| 17 | void test_is_move_assignable() |
| 18 | { |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 19 | static_assert( std::is_move_assignable<T>::value, ""); |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | template <class T> |
| 23 | void test_is_not_move_assignable() |
| 24 | { |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 25 | static_assert(!std::is_move_assignable<T>::value, ""); |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Howard Hinnant | 1468b66 | 2010-11-19 22:17:28 +0000 | [diff] [blame] | 28 | class Empty |
| 29 | { |
| 30 | }; |
| 31 | |
| 32 | class NotEmpty |
| 33 | { |
| 34 | public: |
| 35 | virtual ~NotEmpty(); |
| 36 | }; |
| 37 | |
| 38 | union Union {}; |
| 39 | |
| 40 | struct bit_zero |
| 41 | { |
| 42 | int : 0; |
| 43 | }; |
| 44 | |
| 45 | struct A |
| 46 | { |
| 47 | A(); |
| 48 | }; |
| 49 | |
| 50 | int main() |
| 51 | { |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 52 | test_is_move_assignable<int> (); |
| 53 | test_is_move_assignable<A> (); |
| 54 | test_is_move_assignable<bit_zero> (); |
| 55 | test_is_move_assignable<Union> (); |
| 56 | test_is_move_assignable<NotEmpty> (); |
| 57 | test_is_move_assignable<Empty> (); |
| 58 | |
| 59 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
| 60 | test_is_not_move_assignable<const int> (); |
| 61 | test_is_not_move_assignable<int[]> (); |
| 62 | test_is_not_move_assignable<int[3]> (); |
Marshall Clow | 933afa9 | 2013-07-04 00:10:01 +0000 | [diff] [blame] | 63 | #endif |
| 64 | test_is_not_move_assignable<void> (); |
Howard Hinnant | 1468b66 | 2010-11-19 22:17:28 +0000 | [diff] [blame] | 65 | } |