remove_const.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// remove_const
13
14#include <type_traits>
15
16template <class T, class U>
17void test_remove_const_imp()
18{
19    static_assert((std::is_same<typename std::remove_const<T>::type, U>::value), "");
20#if _LIBCPP_STD_VER > 11
21    static_assert((std::is_same<std::remove_const_t<T>, U>::value), "");
22#endif
23}
24
25template <class T>
26void test_remove_const()
27{
28    test_remove_const_imp<T, T>();
29    test_remove_const_imp<const T, T>();
30    test_remove_const_imp<volatile T, volatile T>();
31    test_remove_const_imp<const volatile T, volatile T>();
32}
33
34int main()
35{
36    test_remove_const<void>();
37    test_remove_const<int>();
38    test_remove_const<int[3]>();
39    test_remove_const<int&>();
40    test_remove_const<const int&>();
41    test_remove_const<int*>();
42    test_remove_const<const int*>();
43}
44