is_assignable.pass.cpp revision 933afa9761c1c1f916161278a99284d50a594939
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_assignable
13
14#include <type_traits>
15
16struct A
17{
18};
19
20struct B
21{
22    void operator=(A);
23};
24
25template <class T, class U>
26void test_is_assignable()
27{
28    static_assert(( std::is_assignable<T, U>::value), "");
29}
30
31template <class T, class U>
32void test_is_not_assignable()
33{
34    static_assert((!std::is_assignable<T, U>::value), "");
35}
36
37int main()
38{
39    test_is_assignable<int&, int&> ();
40    test_is_assignable<int&, int> ();
41    test_is_assignable<int&, double> ();
42    test_is_assignable<B, A> ();
43    test_is_assignable<void*&, void*> ();
44
45#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
46    test_is_not_assignable<int, int&> ();
47    test_is_not_assignable<int, int> ();
48#endif
49    test_is_not_assignable<A, B> ();
50    test_is_not_assignable<void, const void> ();
51    test_is_not_assignable<const void, const void> ();
52    test_is_not_assignable<int(), int> ();
53}
54