Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/c++/15/pstl/execution_impl.h
1 // -*- C++ -*- 2 //===-- execution_impl.h --------------------------------------------------===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef _PSTL_EXECUTION_IMPL_H 11 #define _PSTL_EXECUTION_IMPL_H 12 13 #include <iterator> 14 #include <type_traits> 15 16 #include "execution_defs.h" 17 18 namespace __pstl 19 { 20 namespace __internal 21 { 22 #if __glibcxx_concepts 23 template<typename _Iter> 24 concept __is_random_access_iter 25 = std::is_base_of_v<std::random_access_iterator_tag, 26 std::__iter_category_t<_Iter>> 27 || std::random_access_iterator<_Iter>; 28 29 template <typename... _IteratorTypes> 30 using __are_random_access_iterators 31 = std::bool_constant<(__is_random_access_iter<std::remove_cvref_t<_IteratorTypes>> && ...)>; 32 #else 33 template <typename... _IteratorTypes> 34 using __are_random_access_iterators 35 = std::__and_< 36 std::is_base_of<std::random_access_iterator_tag, 37 std::__iter_category_t<std::__remove_cvref_t<_IteratorTypes>>>... 38 >; 39 #endif 40 41 struct __serial_backend_tag 42 { 43 }; 44 struct __tbb_backend_tag 45 { 46 }; 47 struct __openmp_backend_tag 48 { 49 }; 50 51 #if defined(_PSTL_PAR_BACKEND_TBB) 52 using __par_backend_tag = __tbb_backend_tag; 53 #elif defined(_PSTL_PAR_BACKEND_OPENMP) 54 using __par_backend_tag = __openmp_backend_tag; 55 #elif defined(_PSTL_PAR_BACKEND_SERIAL) 56 using __par_backend_tag = __serial_backend_tag; 57 #else 58 # error "A parallel backend must be specified"; 59 #endif 60 61 template <class _IsVector> 62 struct __serial_tag 63 { 64 using __is_vector = _IsVector; 65 }; 66 67 template <class _IsVector> 68 struct __parallel_tag 69 { 70 using __is_vector = _IsVector; 71 // backend tag can be change depending on 72 // TBB availability in the environment 73 using __backend_tag = __par_backend_tag; 74 }; 75 76 template <class _IsVector, class... _IteratorTypes> 77 using __tag_type = typename std::conditional<__internal::__are_random_access_iterators<_IteratorTypes...>::value, 78 __parallel_tag<_IsVector>, __serial_tag<_IsVector>>::type; 79 80 template <class... _IteratorTypes> 81 __serial_tag</*_IsVector = */ std::false_type> 82 __select_backend(__pstl::execution::sequenced_policy, _IteratorTypes&&...) 83 { 84 return {}; 85 } 86 87 template <class... _IteratorTypes> 88 __serial_tag<__internal::__are_random_access_iterators<_IteratorTypes...>> 89 __select_backend(__pstl::execution::unsequenced_policy, _IteratorTypes&&...) 90 { 91 return {}; 92 } 93 94 template <class... _IteratorTypes> 95 __tag_type</*_IsVector = */ std::false_type, _IteratorTypes...> 96 __select_backend(__pstl::execution::parallel_policy, _IteratorTypes&&...) 97 { 98 return {}; 99 } 100 101 template <class... _IteratorTypes> 102 __tag_type<__internal::__are_random_access_iterators<_IteratorTypes...>, _IteratorTypes...> 103 __select_backend(__pstl::execution::parallel_unsequenced_policy, _IteratorTypes&&...) 104 { 105 return {}; 106 } 107 108 } // namespace __internal 109 } // namespace __pstl 110 111 #endif /* _PSTL_EXECUTION_IMPL_H */