• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // UNSUPPORTED: c++98, c++03, c++11
11 // <experimental/type_traits>
12 
13 #include <experimental/type_traits>
14 #include <string>
15 
16 #include "test_macros.h"
17 
18 namespace ex = std::experimental;
19 
20 template <typename T>
21   using copy_assign_t = decltype(std::declval<T&>() = std::declval<T const &>());
22 
23 struct not_assignable {
24     not_assignable & operator=(const not_assignable&) = delete;
25 };
26 
27 template <typename T, bool b>
test()28 void test() {
29     static_assert( b == ex::is_detected  <copy_assign_t, T>::value, "" );
30     static_assert( b == ex::is_detected_v<copy_assign_t, T>, "" );
31 }
32 
main()33 int main () {
34     test<int, true>();
35     test<std::string, true>();
36     test<not_assignable, false>();
37 }
38