DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
stl_type_traits.hpp
Go to the documentation of this file.
1 //==------- stl_type_traits.hpp - SYCL STL type traits analogs -------------==//
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 #pragma once
10 
12 #include <iterator>
13 #include <memory>
14 #include <type_traits>
15 
17 namespace sycl {
18 namespace detail {
19 
20 // Type traits identical to those in std in newer versions. Can be removed when
21 // SYCL requires a newer version of the C++ standard.
22 // C++14
23 template <bool B, class T = void>
24 using enable_if_t = typename std::enable_if<B, T>::type;
25 
26 template <bool B, class T, class F>
27 using conditional_t = typename std::conditional<B, T, F>::type;
28 
29 template <typename T>
30 using remove_const_t = typename std::remove_const<T>::type;
31 
32 template <typename T> using remove_cv_t = typename std::remove_cv<T>::type;
33 
34 template <typename T>
35 using remove_reference_t = typename std::remove_reference<T>::type;
36 
37 template <typename T> using add_pointer_t = typename std::add_pointer<T>::type;
38 
39 // C++17
40 template <bool V> using bool_constant = std::integral_constant<bool, V>;
41 
42 template <class...> using void_t = void;
43 
44 // Custom type traits
45 template <typename T>
46 using allocator_value_type_t = typename std::allocator_traits<T>::value_type;
47 
48 template <typename T>
49 using allocator_pointer_t = typename std::allocator_traits<T>::pointer;
50 
51 template <typename T>
52 using iterator_category_t = typename std::iterator_traits<T>::iterator_category;
53 
54 template <typename T>
55 using iterator_value_type_t = typename std::iterator_traits<T>::value_type;
56 
57 template <typename T>
58 using iterator_pointer_t = typename std::iterator_traits<T>::pointer;
59 
60 template <typename T>
62  std::is_const<typename std::remove_pointer<iterator_pointer_t<T>>::type>;
63 
64 // TODO Align with C++ named requirements: LegacyOutputIterator
65 // https://en.cppreference.com/w/cpp/named_req/OutputIterator
66 template <typename T>
69  decltype(*std::declval<T>() =
70  std::declval<iterator_value_type_t<T>>())>;
71 
72 template <typename, typename = void> struct is_output_iterator {
73  static constexpr bool value = false;
74 };
75 
76 template <typename T>
78  static constexpr bool value = true;
79 };
80 
81 } // namespace detail
82 } // namespace sycl
83 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::detail::remove_cv_t
typename std::remove_cv< T >::type remove_cv_t
Definition: stl_type_traits.hpp:32
cl::sycl::detail::is_output_iterator
Definition: stl_type_traits.hpp:72
cl::sycl::detail::void_t
void void_t
Definition: stl_type_traits.hpp:42
bool_constant
cl::sycl::detail::remove_reference_t
typename std::remove_reference< T >::type remove_reference_t
Definition: stl_type_traits.hpp:35
cl::sycl::detail::iterator_value_type_t
typename std::iterator_traits< T >::value_type iterator_value_type_t
Definition: stl_type_traits.hpp:55
cl::sycl::detail::conditional_t
typename std::conditional< B, T, F >::type conditional_t
Definition: stl_type_traits.hpp:27
cl::sycl::detail::output_iterator_requirements
void_t< iterator_category_t< T >, decltype(*std::declval< T >()=std::declval< iterator_value_type_t< T > >())> output_iterator_requirements
Definition: stl_type_traits.hpp:70
defines.hpp
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::detail::iterator_to_const_type_t
std::is_const< typename std::remove_pointer< iterator_pointer_t< T > >::type > iterator_to_const_type_t
Definition: stl_type_traits.hpp:62
cl::sycl::detail::add_pointer_t
typename std::add_pointer< T >::type add_pointer_t
Definition: stl_type_traits.hpp:37
cl::sycl::detail::allocator_value_type_t
typename std::allocator_traits< T >::value_type allocator_value_type_t
Definition: stl_type_traits.hpp:46
cl::sycl::detail::remove_const_t
typename std::remove_const< T >::type remove_const_t
Definition: stl_type_traits.hpp:30
cl::sycl::detail::iterator_category_t
typename std::iterator_traits< T >::iterator_category iterator_category_t
Definition: stl_type_traits.hpp:52
cl::sycl::detail::enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Definition: stl_type_traits.hpp:24
cl::sycl::detail::iterator_pointer_t
typename std::iterator_traits< T >::pointer iterator_pointer_t
Definition: stl_type_traits.hpp:58
cl::sycl::detail::allocator_pointer_t
typename std::allocator_traits< T >::pointer allocator_pointer_t
Definition: stl_type_traits.hpp:49
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12