DPC++ Runtime
Runtime libraries for oneAPI DPC++
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 
11 #include <iterator> // for iterator_traits
12 #include <type_traits> // for is_const, remove_pointer_t, void_t
13 #include <utility> // for declval
14 
15 namespace sycl {
16 inline namespace _V1 {
17 namespace detail {
18 
19 // Custom type traits.
20 // FIXME: Those doesn't seem to be a part of any published/future C++ standard
21 // so should probably be moved to a different place.
22 template <typename T>
23 using iterator_category_t = typename std::iterator_traits<T>::iterator_category;
24 
25 template <typename T>
26 using iterator_value_type_t = typename std::iterator_traits<T>::value_type;
27 
28 template <typename T>
29 using iterator_pointer_t = typename std::iterator_traits<T>::pointer;
30 
31 template <typename T>
33  std::is_const<std::remove_pointer_t<iterator_pointer_t<T>>>;
34 
35 // TODO Align with C++ named requirements: LegacyOutputIterator
36 // https://en.cppreference.com/w/cpp/named_req/OutputIterator
37 template <typename T>
39  std::void_t<iterator_category_t<T>,
40  decltype(*std::declval<T>() =
41  std::declval<iterator_value_type_t<T>>())>;
42 
43 template <typename, typename = void> struct is_output_iterator {
44  static constexpr bool value = false;
45 };
46 
47 template <typename T>
49  static constexpr bool value = true;
50 };
51 
52 } // namespace detail
53 } // namespace _V1
54 } // namespace sycl
typename std::iterator_traits< T >::value_type iterator_value_type_t
std::is_const< std::remove_pointer_t< iterator_pointer_t< T > >> iterator_to_const_type_t
typename std::iterator_traits< T >::iterator_category iterator_category_t
std::void_t< iterator_category_t< T >, decltype(*std::declval< T >()=std::declval< iterator_value_type_t< T > >())> output_iterator_requirements
typename std::iterator_traits< T >::pointer iterator_pointer_t
Definition: access.hpp:18