add_const.pass.cpp revision c52f43e72dfcea03037729649da84c23b3beb04a
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// type_traits
11
12// add_const
13
14#include <type_traits>
15
16template <class T, class U>
17void test_add_const_imp()
18{
19    static_assert((std::is_same<typename std::add_const<T>::type, const U>::value), "");
20}
21
22template <class T>
23void test_add_const()
24{
25    test_add_const_imp<T, const T>();
26    test_add_const_imp<const T, const T>();
27    test_add_const_imp<volatile T, volatile const T>();
28    test_add_const_imp<const volatile T, const volatile T>();
29}
30
31int main()
32{
33    test_add_const<void>();
34    test_add_const<int>();
35    test_add_const<int[3]>();
36    test_add_const<int&>();
37    test_add_const<const int&>();
38    test_add_const<int*>();
39    test_add_const<const int*>();
40}
41