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

source code of libcxx/test/std/experimental/utilities/meta/meta.detect/is_detected.pass.cpp