llvm/llvm/unittests/ADT/TypeTraitsTest.cpp

//===- TypeTraitsTest.cpp - type_traits unit tests ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "llvm/ADT/STLExtras.h"
#include "gtest/gtest.h"

usingnamespacellvm;

//===----------------------------------------------------------------------===//
// function_traits
//===----------------------------------------------------------------------===//

namespace {
/// Check a callable type of the form `bool(const int &)`.
template <typename CallableT> struct CheckFunctionTraits {};

/// Test function pointers.
FuncType;
struct CheckFunctionPointer : CheckFunctionTraits<FuncType> {};

/// Test method pointers.
struct Foo {};
struct CheckMethodPointer : CheckFunctionTraits<decltype(&Foo::func)> {};

/// Test lambda references.
LLVM_ATTRIBUTE_UNUSED auto lambdaFunc =;
struct CheckLambda : CheckFunctionTraits<decltype(lambdaFunc)> {};

} // end anonymous namespace

//===----------------------------------------------------------------------===//
// is_detected
//===----------------------------------------------------------------------===//

namespace {
struct HasFooMethod {};
struct NoFooMethod {};

has_foo_method_t;

static_assert;
static_assert;
} // end anonymous namespace