brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 65569bb Raw
62 lines · c
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#ifndef TEST_SUPPORT_TEST_EXECUTION_POLICIES10#define TEST_SUPPORT_TEST_EXECUTION_POLICIES11 12#include <cstdlib>13#include <exception>14#include <execution>15#include <type_traits>16#include <utility>17 18#include "test_macros.h"19 20#define EXECUTION_POLICY_SFINAE_TEST(function)                                                                         \21  template <class, class...>                                                                                           \22  struct sfinae_test_##function##_impl : std::true_type {};                                                            \23                                                                                                                       \24  template <class... Args>                                                                                             \25  struct sfinae_test_##function##_impl<std::void_t<decltype(std::function(std::declval<Args>()...))>, Args...>         \26      : std::false_type {};                                                                                            \27                                                                                                                       \28  template <class... Args>                                                                                             \29  constexpr bool sfinae_test_##function = sfinae_test_##function##_impl<void, Args...>::value;30 31template <class Functor>32bool test_execution_policies(Functor func) {33  func(std::execution::seq);34#if TEST_STD_VER >= 2035  func(std::execution::unseq);36#endif37  func(std::execution::par);38  func(std::execution::par_unseq);39 40  return true;41}42 43template <template <class Iter> class TestClass>44struct TestIteratorWithPolicies {45  template <class Iter>46  void operator()() {47    test_execution_policies(TestClass<Iter>{});48  }49};50 51struct Bool {52  bool b_;53  Bool() = default;54  Bool(bool b) : b_(b) {}55 56  operator bool&() {57    return b_;58  }59};60 61#endif // TEST_SUPPORT_TEST_EXECUTION_POLICIES62