1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 #include <type_traits>
15 #include "test_macros.h"
17 template <class T
, class U
>
20 static_assert(( std::is_same
<T
, U
>::value
), "");
21 static_assert((!std::is_same
<const T
, U
>::value
), "");
22 static_assert((!std::is_same
<T
, const U
>::value
), "");
23 static_assert(( std::is_same
<const T
, const U
>::value
), "");
25 static_assert(( std::is_same_v
<T
, U
>), "");
26 static_assert((!std::is_same_v
<const T
, U
>), "");
27 static_assert((!std::is_same_v
<T
, const U
>), "");
28 static_assert(( std::is_same_v
<const T
, const U
>), "");
32 template <class T
, class U
>
33 void test_is_same_ref()
35 static_assert((std::is_same
<T
, U
>::value
), "");
36 static_assert((std::is_same
<const T
, U
>::value
), "");
37 static_assert((std::is_same
<T
, const U
>::value
), "");
38 static_assert((std::is_same
<const T
, const U
>::value
), "");
40 static_assert((std::is_same_v
<T
, U
>), "");
41 static_assert((std::is_same_v
<const T
, U
>), "");
42 static_assert((std::is_same_v
<T
, const U
>), "");
43 static_assert((std::is_same_v
<const T
, const U
>), "");
47 template <class T
, class U
>
48 void test_is_not_same()
50 static_assert((!std::is_same
<T
, U
>::value
), "");
56 void fn(std::is_same
<T
, int>) { }
57 void fn(std::false_type
) { }
58 void x() { fn(std::false_type()); }
69 test_is_same
<int, int>();
70 test_is_same
<void, void>();
71 test_is_same
<Class
, Class
>();
72 test_is_same
<int*, int*>();
73 test_is_same_ref
<int&, int&>();
75 test_is_not_same
<int, void>();
76 test_is_not_same
<void, Class
>();
77 test_is_not_same
<Class
, int*>();
78 test_is_not_same
<int*, int&>();
79 test_is_not_same
<int&, int>();