brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1016 B · 1928b7f Raw
42 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++1110// <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 hasFoo = typename T::Foo;21 22struct yesFoo {23    using Foo = int;24};25 26struct noFoo {27};28 29 30template <typename T, typename Res>31void test() {32    static_assert( std::is_same<Res, typename ex::detected_or  <double, hasFoo, T>::type>::value, "" );33    static_assert( std::is_same<Res, typename ex::detected_or_t<double, hasFoo, T>      >::value, "" );34}35 36int main(int, char**) {37    test<yesFoo, int>();38    test<noFoo, double>();39 40  return 0;41}42