Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // type_traits |
| 11 | |
| 12 | // is_const |
| 13 | |
| 14 | #include <type_traits> |
| 15 | |
| 16 | template <class T> |
| 17 | void test_is_const() |
| 18 | { |
| 19 | static_assert(!std::is_const<T>::value, ""); |
| 20 | static_assert( std::is_const<const T>::value, ""); |
| 21 | static_assert(!std::is_const<volatile T>::value, ""); |
| 22 | static_assert( std::is_const<const volatile T>::value, ""); |
| 23 | } |
| 24 | |
| 25 | int main() |
| 26 | { |
| 27 | test_is_const<void>(); |
| 28 | test_is_const<int>(); |
| 29 | test_is_const<double>(); |
| 30 | test_is_const<int*>(); |
| 31 | test_is_const<const int*>(); |
| 32 | test_is_const<char[3]>(); |
Marshall Clow | e33e03e | 2014-09-02 16:19:38 +0000 | [diff] [blame] | 33 | test_is_const<char[]>(); |
Howard Hinnant | c52f43e | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 34 | |
| 35 | static_assert(!std::is_const<int&>::value, ""); |
| 36 | static_assert(!std::is_const<const int&>::value, ""); |
| 37 | } |